taxtank-core 0.31.49 → 0.31.51

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.
@@ -1884,7 +1884,7 @@ class Collection {
1884
1884
  return this.items.reduce((prev, current) => (get(prev, path) > get(current, path) ? prev : current));
1885
1885
  }
1886
1886
  reduce(callback, init = 0) {
1887
- return round(this.items.reduce(callback, init), 2);
1887
+ return this.items.reduce(callback, init);
1888
1888
  }
1889
1889
  slice(from, to) {
1890
1890
  this.items.slice(from, to);
@@ -10659,6 +10659,10 @@ let RestService$1 = class RestService extends DataService {
10659
10659
  */
10660
10660
  fetch(path = this.apiUrl) {
10661
10661
  this.handleAccessError('get');
10662
+ if (!this.hasRoles()) {
10663
+ this.setCache([], true);
10664
+ return this.cacheSubject.asObservable();
10665
+ }
10662
10666
  // Set cache as empty collection to avoid multiple requests before cache filled
10663
10667
  this.setCache([]);
10664
10668
  return this.http.get(path)
@@ -10846,6 +10850,15 @@ let RestService$1 = class RestService extends DataService {
10846
10850
  });
10847
10851
  });
10848
10852
  }
10853
+ /**
10854
+ * check if user has subscription role to access api
10855
+ */
10856
+ hasRoles() {
10857
+ if (!this.roles.length) {
10858
+ return true;
10859
+ }
10860
+ return !!intersection(JSON.parse(localStorage.getItem('roles')), this.roles).length;
10861
+ }
10849
10862
  /**
10850
10863
  * // @TODO Alex remove
10851
10864
  * Method that call all listeners. Empty by default. Should be redefined by child services if required
@@ -11526,6 +11539,10 @@ class ChatService extends RestService$1 {
11526
11539
  this.listenChats();
11527
11540
  this.listenMessages();
11528
11541
  }
11542
+ get(path = this.apiUrl) {
11543
+ // users contact ttAdvisor through intercom support
11544
+ return super.get(path).pipe(map((chats) => chats.filter((chat) => chat.employee.email !== this.environment.ttAdvisor)));
11545
+ }
11529
11546
  /**
11530
11547
  * Listen chats events
11531
11548
  */
@@ -15522,8 +15539,10 @@ class UserService extends RestService$1 {
15522
15539
  }
15523
15540
  fetch() {
15524
15541
  return super.fetch(`${this.apiUrl}/current`).pipe(map((users) => {
15542
+ // @TODO vik use separated service to handle global user storage
15525
15543
  localStorage.setItem('userId', this.getCacheFirst().id.toString());
15526
15544
  localStorage.setItem('financialYear', this.getCacheFirst().financialYear.toString());
15545
+ localStorage.setItem('roles', JSON.stringify(this.getCacheFirst().roles));
15527
15546
  this.mpService.identify(this.getCacheFirst().id);
15528
15547
  return users;
15529
15548
  }));
@@ -19892,7 +19911,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
19892
19911
  class AppCurrencyPipe extends CurrencyPipe {
19893
19912
  transform(value, currencyCode, display, digitsInfo, locale) {
19894
19913
  // 2 non-zero decimals by default (43.43344 => 43.43, 0.0000114201553151 => $0.000011)
19895
- digitsInfo = digitsInfo ?? '1.0-' + (value.toString().match(/[1-9]/).index || 2);
19914
+ digitsInfo = digitsInfo ?? '1.0-' + (value.toString().match(/[1-9]/)?.index || 2);
19896
19915
  return super.transform(value, currencyCode, display, digitsInfo, locale);
19897
19916
  }
19898
19917
  }
@@ -20684,7 +20703,7 @@ class DocumentForm extends AbstractForm {
20684
20703
  constructor(document) {
20685
20704
  super({
20686
20705
  folder: new FormControl(document.folder, Validators.required),
20687
- file: new FormControl(document.file)
20706
+ file: new FormControl(document.file, Validators.required),
20688
20707
  }, document);
20689
20708
  }
20690
20709
  }