taxtank-core 0.32.57 → 0.32.59

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.
@@ -10845,7 +10845,7 @@ let RestService$1 = class RestService extends DataService {
10845
10845
  return this.get().pipe(map((collection) => collection.first));
10846
10846
  }
10847
10847
  hasInCache(id) {
10848
- return !!this.getCache().findBy('id', id);
10848
+ return !!this.getCache()?.findBy('id', id);
10849
10849
  }
10850
10850
  getArray() {
10851
10851
  return this.get().pipe(map((collection) => collection.toArray()));
@@ -11013,7 +11013,7 @@ let RestService$1 = class RestService extends DataService {
11013
11013
  * Listen for Server-Sent Events (SSE) on the specified Mercure topic
11014
11014
  */
11015
11015
  listenSSE() {
11016
- if (!this.mercureTopic || !this.cache) {
11016
+ if (!this.mercureTopic) {
11017
11017
  return;
11018
11018
  }
11019
11019
  this.sseService.on(this.mercureTopic).pipe(map((response) => {
@@ -11682,7 +11682,6 @@ class ChatService extends RestService$1 {
11682
11682
  listenMessages() {
11683
11683
  this.listenCSE(Message, (messages) => {
11684
11684
  const message = messages[0];
11685
- console.log(message);
11686
11685
  const cache = this.cache.toArray();
11687
11686
  const updatedChat = cache.find((chat) => chat?.id === message.chat?.id);
11688
11687
  // @TODO vik
@@ -12223,9 +12222,11 @@ class ClientInviteService extends RestService$1 {
12223
12222
  resend(invite) {
12224
12223
  // cant use parent method because of custom specific handler
12225
12224
  return this.http.post(`${this.apiUrl}/${invite.id}/resend`, null)
12226
- .pipe(map((inviteBase) => plainToClass(ClientInvite, inviteBase)), map((resentInvite) =>
12227
- // this.handleResponse([resentInvite], 'put');
12228
- resentInvite));
12225
+ .pipe(map((inviteBase) => {
12226
+ const resentInvite = plainToClass(ClientInvite, inviteBase);
12227
+ this.handleResponse([resentInvite], 'put');
12228
+ return resentInvite;
12229
+ }));
12229
12230
  }
12230
12231
  /**
12231
12232
  * Send invitation from client to firm
@@ -12366,8 +12367,8 @@ class EmployeeService extends RestService$1 {
12366
12367
  this.endpointUri = 'employees';
12367
12368
  this.modelClass = User;
12368
12369
  this.collectionClass = (Collection);
12369
- this.disabledMethods = ['postBatch', 'putBatch'];
12370
12370
  this.messages = EmployeeMessagesEnum;
12371
+ this.roles = [UserRolesEnum.FIRM_MANAGER];
12371
12372
  }
12372
12373
  activateEmployee(employee) {
12373
12374
  return super.put(employee, `${this.environment.apiV2}/${this.endpointUri}/${employee.id}/activate`);
@@ -12401,6 +12402,139 @@ __decorate([
12401
12402
  Type(() => User)
12402
12403
  ], EmployeeInvite.prototype, "employee", void 0);
12403
12404
 
12405
+ class EmployeeInviteService extends RestService$1 {
12406
+ constructor() {
12407
+ super(...arguments);
12408
+ this.endpointUri = 'employees/invites';
12409
+ this.collectionClass = (Collection);
12410
+ this.disabledMethods = ['postBatch', 'putBatch'];
12411
+ this.modelClass = EmployeeInvite;
12412
+ this.roles = [UserRolesEnum.FIRM_MANAGER];
12413
+ }
12414
+ /**
12415
+ * Import employees for firm from CSV file
12416
+ * @param file
12417
+ */
12418
+ import(file) {
12419
+ const formData = new FormData();
12420
+ formData.append('file', file);
12421
+ return this.http.post(`${this.environment.apiV2}/${this.endpointUri}/import`, formData)
12422
+ .pipe(map((employeeInvite) => employeeInvite));
12423
+ }
12424
+ /**
12425
+ * Resend invitation from firm to client
12426
+ * @param invite
12427
+ */
12428
+ resend(invite) {
12429
+ return this.http.post(`${this.environment.apiV2}/${this.endpointUri}/${invite.id}/resend`, null)
12430
+ .pipe(map((resentInviteBase) => {
12431
+ const updatedInvite = plainToClass(EmployeeInvite, resentInviteBase);
12432
+ this.handleResponse([updatedInvite], 'put');
12433
+ return updatedInvite;
12434
+ }));
12435
+ }
12436
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EmployeeInviteService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12437
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EmployeeInviteService, providedIn: 'root' }); }
12438
+ }
12439
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EmployeeInviteService, decorators: [{
12440
+ type: Injectable,
12441
+ args: [{
12442
+ providedIn: 'root'
12443
+ }]
12444
+ }] });
12445
+
12446
+ // @Todo refactor with BaseRest service
12447
+ /**
12448
+ * Service to work with employee clients tax summary data
12449
+ */
12450
+ class ClientPortfolioReportService {
12451
+ constructor(http, environment) {
12452
+ this.http = http;
12453
+ this.environment = environment;
12454
+ this.url = 'portfolio-reports';
12455
+ }
12456
+ get() {
12457
+ return this.http.get(`${this.environment.apiV2}/${this.url}`)
12458
+ .pipe(map((response) => {
12459
+ const clientReports = response.map((item) => plainToClass(ClientPortfolioReport, item));
12460
+ return new ClientPortfolioReportCollection(clientReports);
12461
+ }));
12462
+ }
12463
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientPortfolioReportService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
12464
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientPortfolioReportService, providedIn: 'root' }); }
12465
+ }
12466
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientPortfolioReportService, decorators: [{
12467
+ type: Injectable,
12468
+ args: [{
12469
+ providedIn: 'root'
12470
+ }]
12471
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
12472
+ type: Inject,
12473
+ args: ['environment']
12474
+ }] }]; } });
12475
+
12476
+ var FirmMessagesEnum;
12477
+ (function (FirmMessagesEnum) {
12478
+ FirmMessagesEnum["LOGO_UPDATED"] = "Firm logo updated";
12479
+ FirmMessagesEnum["DATA_UPDATED"] = "Firm data updated";
12480
+ })(FirmMessagesEnum || (FirmMessagesEnum = {}));
12481
+
12482
+ // @TODO Alex: think about extend base rest service
12483
+ class FirmService {
12484
+ constructor(http, environment) {
12485
+ this.http = http;
12486
+ this.environment = environment;
12487
+ this.firmSubject = new ReplaySubject(1);
12488
+ }
12489
+ /**
12490
+ * Register new firm
12491
+ * @param data: firm and firm owner data to register
12492
+ */
12493
+ register(data) {
12494
+ return this.http.post(`${this.environment.apiV2}/firms/registration`, data)
12495
+ .pipe(map((firm) => plainToClass(Firm, firm)));
12496
+ }
12497
+ get() {
12498
+ if (!this.firm) {
12499
+ this.http.get(`${this.environment.apiV2}/firms/current`)
12500
+ .pipe(map((firm) => plainToClass(Firm, firm)))
12501
+ .subscribe((firm) => {
12502
+ this.firm = firm;
12503
+ this.firmSubject.next(this.firm);
12504
+ });
12505
+ }
12506
+ return this.firmSubject.asObservable();
12507
+ }
12508
+ update(firm) {
12509
+ return this.http.put(`${this.environment.apiV2}/firms/current`, firm)
12510
+ .pipe(map((updatedItem) => {
12511
+ const updatedInstance = plainToClass(Firm, updatedItem);
12512
+ this.firmSubject.next(updatedInstance);
12513
+ }));
12514
+ }
12515
+ /**
12516
+ * get list of all registered firms
12517
+ */
12518
+ getAll() {
12519
+ return this.http.get(`${this.environment.apiV2}/firms`)
12520
+ .pipe(map((response) => response.map((firmBase) => plainToClass(Firm, firmBase))));
12521
+ }
12522
+ getByType(type) {
12523
+ return this.getAll().pipe(map((firms) => firms.filter((firm) => firm.type === type)));
12524
+ }
12525
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FirmService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
12526
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FirmService, providedIn: 'root' }); }
12527
+ }
12528
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FirmService, decorators: [{
12529
+ type: Injectable,
12530
+ args: [{
12531
+ providedIn: 'root'
12532
+ }]
12533
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
12534
+ type: Inject,
12535
+ args: ['environment']
12536
+ }] }]; } });
12537
+
12404
12538
  /**
12405
12539
  * Abstract base service that implements common services functionality
12406
12540
  * and describe abstract methods/properties that have to be implemented in child services
@@ -12632,141 +12766,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
12632
12766
  args: ['environment']
12633
12767
  }] }]; } });
12634
12768
 
12635
- class EmployeeInviteService extends RestService {
12636
- constructor() {
12637
- super(...arguments);
12638
- this.url = 'employees/invites';
12639
- this.modelClass = EmployeeInvite;
12640
- }
12641
- /**
12642
- * Import employees for firm from CSV file
12643
- * @param file
12644
- */
12645
- import(file) {
12646
- const formData = new FormData();
12647
- formData.append('file', file);
12648
- return this.http.post(`${this.environment.apiV2}/${this.url}/import`, formData)
12649
- .pipe(map((employeeInvite) => employeeInvite));
12650
- }
12651
- /**
12652
- * Resend invitation from firm to client
12653
- * @param invite
12654
- */
12655
- resend(invite) {
12656
- return this.http.post(`${this.environment.apiV2}/${this.url}/${invite.id}/resend`, null)
12657
- .pipe(map((resentInviteBase) => {
12658
- const updatedInvite = plainToClass(EmployeeInvite, resentInviteBase);
12659
- // avoid cache changes
12660
- // @TODO make cache readonly
12661
- const tempCache = _.cloneDeep(this.cache);
12662
- replace(tempCache, plainToClass(EmployeeInvite, updatedInvite));
12663
- this.cache = tempCache;
12664
- this.updateCache();
12665
- return updatedInvite;
12666
- }));
12667
- }
12668
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EmployeeInviteService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12669
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EmployeeInviteService, providedIn: 'root' }); }
12670
- }
12671
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EmployeeInviteService, decorators: [{
12672
- type: Injectable,
12673
- args: [{
12674
- providedIn: 'root'
12675
- }]
12676
- }] });
12677
-
12678
- // @Todo refactor with BaseRest service
12679
- /**
12680
- * Service to work with employee clients tax summary data
12681
- */
12682
- class ClientPortfolioReportService {
12683
- constructor(http, environment) {
12684
- this.http = http;
12685
- this.environment = environment;
12686
- this.url = 'portfolio-reports';
12687
- }
12688
- get() {
12689
- return this.http.get(`${this.environment.apiV2}/${this.url}`)
12690
- .pipe(map((response) => {
12691
- const clientReports = response.map((item) => plainToClass(ClientPortfolioReport, item));
12692
- return new ClientPortfolioReportCollection(clientReports);
12693
- }));
12694
- }
12695
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientPortfolioReportService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
12696
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientPortfolioReportService, providedIn: 'root' }); }
12697
- }
12698
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientPortfolioReportService, decorators: [{
12699
- type: Injectable,
12700
- args: [{
12701
- providedIn: 'root'
12702
- }]
12703
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
12704
- type: Inject,
12705
- args: ['environment']
12706
- }] }]; } });
12707
-
12708
- var FirmMessagesEnum;
12709
- (function (FirmMessagesEnum) {
12710
- FirmMessagesEnum["LOGO_UPDATED"] = "Firm logo updated";
12711
- FirmMessagesEnum["DATA_UPDATED"] = "Firm data updated";
12712
- })(FirmMessagesEnum || (FirmMessagesEnum = {}));
12713
-
12714
- // @TODO Alex: think about extend base rest service
12715
- class FirmService {
12716
- constructor(http, environment) {
12717
- this.http = http;
12718
- this.environment = environment;
12719
- this.firmSubject = new ReplaySubject(1);
12720
- }
12721
- /**
12722
- * Register new firm
12723
- * @param data: firm and firm owner data to register
12724
- */
12725
- register(data) {
12726
- return this.http.post(`${this.environment.apiV2}/firms/registration`, data)
12727
- .pipe(map((firm) => plainToClass(Firm, firm)));
12728
- }
12729
- get() {
12730
- if (!this.firm) {
12731
- this.http.get(`${this.environment.apiV2}/firms/current`)
12732
- .pipe(map((firm) => plainToClass(Firm, firm)))
12733
- .subscribe((firm) => {
12734
- this.firm = firm;
12735
- this.firmSubject.next(this.firm);
12736
- });
12737
- }
12738
- return this.firmSubject.asObservable();
12739
- }
12740
- update(firm) {
12741
- return this.http.put(`${this.environment.apiV2}/firms/current`, firm)
12742
- .pipe(map((updatedItem) => {
12743
- const updatedInstance = plainToClass(Firm, updatedItem);
12744
- this.firmSubject.next(updatedInstance);
12745
- }));
12746
- }
12747
- /**
12748
- * get list of all registered firms
12749
- */
12750
- getAll() {
12751
- return this.http.get(`${this.environment.apiV2}/firms`)
12752
- .pipe(map((response) => response.map((firmBase) => plainToClass(Firm, firmBase))));
12753
- }
12754
- getByType(type) {
12755
- return this.getAll().pipe(map((firms) => firms.filter((firm) => firm.type === type)));
12756
- }
12757
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FirmService, deps: [{ token: i1.HttpClient }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
12758
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FirmService, providedIn: 'root' }); }
12759
- }
12760
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FirmService, decorators: [{
12761
- type: Injectable,
12762
- args: [{
12763
- providedIn: 'root'
12764
- }]
12765
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
12766
- type: Inject,
12767
- args: ['environment']
12768
- }] }]; } });
12769
-
12770
12769
  /**
12771
12770
  * Service to work with Other Income Forecasts
12772
12771
  */
@@ -15074,8 +15073,10 @@ class YoutubeService {
15074
15073
  this.http = http;
15075
15074
  this.environment = environment;
15076
15075
  }
15077
- getTutorials() {
15078
- return this.http.get(`${YoutubeService.googleUrl}&playlistId=${this.environment.tutorialPlaylistId}&key=${this.environment.googleAPIKey}&maxResults=${YoutubeService.maxResults}`)
15076
+ getTutorials(user) {
15077
+ const playlistId = user.isClient() ? this.environment.playlistId
15078
+ : user.isAdvisor() ? this.environment.advisorPlaylistId : this.environment.accountantPlaylistId;
15079
+ return this.http.get(`${YoutubeService.googleUrl}&playlistId=${playlistId}&key=${this.environment.googleAPIKey}&maxResults=${YoutubeService.maxResults}`)
15079
15080
  .pipe(map((response) => response.items.map((item) => ({
15080
15081
  id: item.snippet.resourceId.videoId,
15081
15082
  title: item.snippet.title
@@ -18061,7 +18062,7 @@ class AccountSetupService {
18061
18062
  // Invite team item is completed when firm has employees except firm owner or firm has invited employees.
18062
18063
  this.setItemStatus(this.items.findBy('isInviteTeam', true), combineLatest([
18063
18064
  this.employeeService.getArray(),
18064
- this.employeeInviteService.get()
18065
+ this.employeeInviteService.getArray()
18065
18066
  ]).pipe(map(([employees, invites]) => {
18066
18067
  // we always have at least 1 employee (firm owner), so we should check other employees except firm owner
18067
18068
  if (employees.length) {
@@ -22651,13 +22652,24 @@ class VehicleLogbookForm extends AbstractForm {
22651
22652
  }
22652
22653
  }
22653
22654
 
22655
+ /**
22656
+ * Custom validator that applies another validator to all controls in a FormGroup
22657
+ */
22658
+ function groupValidator(validatorFn) {
22659
+ return (control) => {
22660
+ const keys = Object.keys(control.controls);
22661
+ const errors = keys.map(key => validatorFn(control.get(key))).filter(Boolean);
22662
+ return errors.length === keys.length ? errors[0] : null;
22663
+ };
22664
+ }
22665
+
22654
22666
  class AllocationRuleConditionForm extends AbstractForm {
22655
22667
  constructor(condition = plainToClass(AllocationRuleCondition, {})) {
22656
22668
  super({
22657
22669
  field: new UntypedFormControl(condition.field, Validators.required),
22658
22670
  comparisonOperator: new UntypedFormControl(condition.comparisonOperator, Validators.required),
22659
22671
  value: new UntypedFormControl(condition.value, Validators.required)
22660
- }, condition);
22672
+ }, condition, groupValidator(RxwebValidators.unique()));
22661
22673
  }
22662
22674
  }
22663
22675