taxtank-core 2.0.110 → 2.0.112

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.
@@ -3,9 +3,9 @@ import { Inject, Injectable, inject, NgModule, EventEmitter, InjectionToken, Pip
3
3
  import * as i1$1 from '@angular/common';
4
4
  import { formatDate, DatePipe, CurrencyPipe, CommonModule as CommonModule$1 } from '@angular/common';
5
5
  import * as i1 from '@angular/common/http';
6
- import { HttpClient, HttpErrorResponse, HttpHeaders, HTTP_INTERCEPTORS, HttpParams } from '@angular/common/http';
6
+ import { HttpClient, HttpErrorResponse, HTTP_INTERCEPTORS, HttpHeaders, HttpParams } from '@angular/common/http';
7
7
  import { map, filter, catchError, finalize, switchMap, first as first$1, take, mergeMap, startWith, debounceTime, distinctUntilChanged } from 'rxjs/operators';
8
- import { ReplaySubject, Subject, Observable, shareReplay, of, forkJoin, throwError, concatMap, BehaviorSubject, combineLatest, from, merge as merge$1 } from 'rxjs';
8
+ import { ReplaySubject, Subject, Observable, shareReplay, of, forkJoin, throwError, BehaviorSubject, concatMap, combineLatest, from, merge as merge$1 } from 'rxjs';
9
9
  import { plainToClass, Type, Transform, Exclude, Expose, classToPlain } from 'class-transformer';
10
10
  import get from 'lodash/get';
11
11
  import 'reflect-metadata';
@@ -32,12 +32,12 @@ import moment$1 from 'moment/moment';
32
32
  import { EventSourcePolyfill } from 'event-source-polyfill/src/eventsource.min.js';
33
33
  import clone from 'lodash/clone';
34
34
  import merge from 'lodash/merge';
35
+ import remove from 'lodash/remove';
35
36
  import mixpanel from 'mixpanel-browser';
36
37
  import { JwtHelperService } from '@auth0/angular-jwt';
37
38
  import * as i4 from '@angular/router';
38
39
  import { NavigationEnd } from '@angular/router';
39
40
  import _ from 'lodash';
40
- import remove from 'lodash/remove';
41
41
  import pick from 'lodash/pick';
42
42
  import { checkAdBlock } from 'adblock-checker';
43
43
  import { jsPDF } from 'jspdf';
@@ -755,10 +755,6 @@ class BasiqToken extends AbstractModel {
755
755
  }
756
756
 
757
757
  class BasiqUser extends AbstractModel {
758
- constructor() {
759
- super(...arguments);
760
- this.name = 'Profile1';
761
- }
762
758
  /**
763
759
  * reminder to sign basiq consent after x days before the expiration
764
760
  */
@@ -7239,13 +7235,13 @@ class Depreciation extends Depreciation$1 {
7239
7235
  */
7240
7236
  toTransaction(params = {}) {
7241
7237
  const claimPercent = this.currentYearForecast?.claimPercent || 0;
7242
- return plainToClass(Transaction, Object.assign(params, this, {
7238
+ return plainToClass(Transaction, Object.assign({}, this, {
7243
7239
  amount: -this.currentYearForecast?.amount || 0,
7244
7240
  claimAmount: -this.currentYearForecast?.claimAmount || 0,
7245
7241
  claimPercent: claimPercent,
7246
7242
  date: this.currentYearForecast?.fromDate ?? this.date,
7247
7243
  sharedClaimPercent: claimPercent,
7248
- }));
7244
+ }, params));
7249
7245
  }
7250
7246
  /**
7251
7247
  * @TODO Michael: remove and check everywhere in reports
@@ -12595,6 +12591,9 @@ let RestService$1 = class RestService extends DataService {
12595
12591
  hasInCache(id) {
12596
12592
  return !!this.getCache()?.findBy('id', id);
12597
12593
  }
12594
+ fromCache(id) {
12595
+ return this.getCache()?.findBy('id', id);
12596
+ }
12598
12597
  getArray() {
12599
12598
  return this.get().pipe(map((collection) => collection.toArray()));
12600
12599
  }
@@ -12918,7 +12917,7 @@ class BankAccountService extends RestService$1 {
12918
12917
  this.modelClass = BankAccount;
12919
12918
  this.collectionClass = BankAccountCollection;
12920
12919
  this.disabledMethods = ['post', 'putBatch', 'delete', 'deleteBatch'];
12921
- this.roles = [UserRolesEnum$1.WORK_TANK, UserRolesEnum$1.PROPERTY_TANK, UserRolesEnum$1.SOLE_TANK, UserRolesEnum$1.MONEY_TANK];
12920
+ this.roles = [UserRolesEnum$1.SUBSCRIPTION];
12922
12921
  this.listenEvents();
12923
12922
  }
12924
12923
  getActive() {
@@ -13055,6 +13054,12 @@ class BankConnectionService extends RestService$1 {
13055
13054
  break;
13056
13055
  }
13057
13056
  }
13057
+ //
13058
+ const connection = this.fromCache(result.id);
13059
+ if (connection.isReconnecting()) {
13060
+ remove(this.cache.items, { id: result.id, status: BankConnectionStatusEnum.RECONNECTING });
13061
+ this.setCache(this.cache.items, true);
13062
+ }
13058
13063
  return result;
13059
13064
  }), catchError((error) => {
13060
13065
  // Show error when user provided wrong login data
@@ -13071,6 +13076,13 @@ class BankConnectionService extends RestService$1 {
13071
13076
  return throwError(error);
13072
13077
  }));
13073
13078
  }
13079
+ /**
13080
+ * remove basiq connection to create a new one (because basiq has no update option),
13081
+ * used for upgrade to openBanking and manage shared bank accounts flow
13082
+ */
13083
+ deleteBasiq(connection) {
13084
+ return this.put(connection, `${this.apiUrl}/${connection.id}/remove-basiq`);
13085
+ }
13074
13086
  activate(bankConnection) {
13075
13087
  return this.put(bankConnection, `${this.apiUrl}/${bankConnection.id}/activate`);
13076
13088
  }
@@ -13236,17 +13248,6 @@ class BasiqService extends RestService$1 {
13236
13248
  listenEvents() {
13237
13249
  this.listenNotifications();
13238
13250
  }
13239
- /**
13240
- * remove basiq connection to create a new one (because basiq has no update option),
13241
- * used for upgrade to openBanking and manage shared bank accounts flow
13242
- */
13243
- deleteBasiq(connection) {
13244
- return this.http.put(`${this.environment.apiV2}/bank-connections/${connection.id}/remove-basiq`, {})
13245
- .pipe(map((connection) => connection
13246
- // @TODO Alex token should be inside this service
13247
- // this.redirectToBasiqConsent(token.value, connection.bank.externalId, true);
13248
- ));
13249
- }
13250
13251
  /**
13251
13252
  * listen to notifications to update basiq accounts list
13252
13253
  */
@@ -13277,134 +13278,6 @@ var BasiqMessagesEnum;
13277
13278
  BasiqMessagesEnum["REVOKE_SUCCESS"] = "Consent to bank feeds has been revoked.";
13278
13279
  })(BasiqMessagesEnum || (BasiqMessagesEnum = {}));
13279
13280
 
13280
- class BasiqUserService extends RestService$1 {
13281
- constructor() {
13282
- super(...arguments);
13283
- this.endpointUri = 'basiq-users';
13284
- this.modelClass = BasiqUser;
13285
- this.collectionClass = Collection;
13286
- this.disabledMethods = ['postBatch', 'put', 'putBatch', 'delete', 'deleteBatch'];
13287
- this.basiqTokenService = inject(BasiqTokenService);
13288
- }
13289
- static { this.basiqApiUrl = 'https://au-api.basiq.io'; }
13290
- static { this.basiqConsentUrl = 'https://consent.basiq.io/home'; }
13291
- revokeConsent() {
13292
- return this.http.put(`${this.environment.apiV2}/basiq-users/consents/revoke`, {});
13293
- }
13294
- post(basiqUser = new BasiqUser()) {
13295
- return super.post(basiqUser);
13296
- }
13297
- retrieveJob(jobId, basiqUserId) {
13298
- return this.basiqTokenService.getOne(basiqUserId).pipe(concatMap(token => {
13299
- const headers = new HttpHeaders({ Authorization: 'Bearer ' + token.value });
13300
- return this.http.get(`${BasiqUserService.basiqApiUrl}/jobs/${jobId}`, { headers })
13301
- .pipe(map((response) => plainToClass(BasiqJobResponse, response)));
13302
- }));
13303
- }
13304
- /**
13305
- * Open basiq consent ui to allow user to log in to bank
13306
- */
13307
- redirectToBasiqConsent(bankId, basiqUserId) {
13308
- const user$ = basiqUserId ? this.findBy('id', basiqUserId) : this.post();
13309
- return user$.pipe(filter(user => !!user), concatMap(user => this.basiqTokenService.getOne(user.id).pipe(map(token => ({ user, token: token })))), map(({ user, token }) => {
13310
- const url = new URL(BasiqUserService.basiqConsentUrl);
13311
- url.searchParams.set('token', token.value);
13312
- url.searchParams.set('institutionId', bankId);
13313
- url.searchParams.set('state', user.id);
13314
- if (user.consentId) {
13315
- url.searchParams.set('action', 'connect');
13316
- }
13317
- window.location.replace(url.toString());
13318
- }));
13319
- }
13320
- /**
13321
- * Open basiq consent ui to allow user to manage basiq access to his bank data
13322
- */
13323
- redirectToBasiqRevoke(basiqUserId) {
13324
- return this.basiqTokenService.getOne(basiqUserId).pipe(map(token => {
13325
- window.location.replace(`${BasiqUserService.basiqConsentUrl}?token=${token.value}&action=manage`);
13326
- }));
13327
- }
13328
- /**
13329
- * redirect to basiq extend consent date to prolong it
13330
- */
13331
- extendConsent(basiqUserId) {
13332
- return this.basiqTokenService.getOne(basiqUserId).pipe(map(token => {
13333
- window.location.replace(`${BasiqUserService.basiqConsentUrl}?token=${token.value}&action=extend`);
13334
- }));
13335
- }
13336
- /**
13337
- * redirect to basiq extend connection date to prolong it
13338
- */
13339
- reauthoriseConnection(connection) {
13340
- return this.basiqTokenService.getOne(connection.basiqUser.id).pipe(map(token => {
13341
- let url = `${BasiqUserService.basiqConsentUrl}?token=${token.value}&action=reauthorise`;
13342
- if (connection.isExpiring()) {
13343
- url += `&connectionId=${connection.externalId}`;
13344
- }
13345
- window.location.replace(url);
13346
- }));
13347
- }
13348
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasiqUserService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
13349
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasiqUserService, providedIn: 'root' }); }
13350
- }
13351
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasiqUserService, decorators: [{
13352
- type: Injectable,
13353
- args: [{
13354
- providedIn: 'root'
13355
- }]
13356
- }] });
13357
-
13358
- /**
13359
- * Service that handling banks logic
13360
- */
13361
- class BankTransactionCommentService extends RestService$1 {
13362
- constructor() {
13363
- super(...arguments);
13364
- this.modelClass = BankTransactionComment;
13365
- this.collectionClass = Collection;
13366
- this.endpointUri = 'bank-transaction-comments';
13367
- this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
13368
- }
13369
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankTransactionCommentService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
13370
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankTransactionCommentService, providedIn: 'root' }); }
13371
- }
13372
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankTransactionCommentService, decorators: [{
13373
- type: Injectable,
13374
- args: [{
13375
- providedIn: 'root'
13376
- }]
13377
- }] });
13378
-
13379
- var BankTransactionCommentMessagesEnum;
13380
- (function (BankTransactionCommentMessagesEnum) {
13381
- BankTransactionCommentMessagesEnum["CREATED"] = "Note created";
13382
- BankTransactionCommentMessagesEnum["UPDATED"] = "Note updated";
13383
- BankTransactionCommentMessagesEnum["DELETED"] = "Note deleted";
13384
- BankTransactionCommentMessagesEnum["CONFIRM_DELETE"] = "Are you sure you want to delete this note?";
13385
- })(BankTransactionCommentMessagesEnum || (BankTransactionCommentMessagesEnum = {}));
13386
-
13387
- /**
13388
- * Service that handling banks logic
13389
- */
13390
- class BankService extends RestService$1 {
13391
- constructor() {
13392
- super(...arguments);
13393
- this.modelClass = Bank;
13394
- this.collectionClass = Collection;
13395
- this.endpointUri = 'banks';
13396
- this.disabledMethods = ['post', 'postBatch', 'put', 'putBatch', 'delete', 'deleteBatch'];
13397
- }
13398
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
13399
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankService, providedIn: 'root' }); }
13400
- }
13401
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankService, decorators: [{
13402
- type: Injectable,
13403
- args: [{
13404
- providedIn: 'root'
13405
- }]
13406
- }] });
13407
-
13408
13281
  /**
13409
13282
  * Service to work with mixpanel https://docs.mixpanel.com/docs/tracking/reference/javascript
13410
13283
  */
@@ -13771,6 +13644,129 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImpo
13771
13644
  }]
13772
13645
  }] });
13773
13646
 
13647
+ class BasiqUserService extends RestService$1 {
13648
+ constructor() {
13649
+ super(...arguments);
13650
+ this.endpointUri = 'basiq-users';
13651
+ this.modelClass = BasiqUser;
13652
+ this.collectionClass = Collection;
13653
+ this.disabledMethods = ['postBatch', 'put', 'putBatch', 'delete', 'deleteBatch'];
13654
+ this.roles = [UserRolesEnum.SUBSCRIPTION];
13655
+ this.basiqTokenService = inject(BasiqTokenService);
13656
+ }
13657
+ static { this.basiqApiUrl = 'https://au-api.basiq.io'; }
13658
+ static { this.basiqConsentUrl = 'https://consent.basiq.io/home'; }
13659
+ revokeConsent() {
13660
+ return this.http.put(`${this.environment.apiV2}/basiq-users/consents/revoke`, {});
13661
+ }
13662
+ post(basiqUser = new BasiqUser()) {
13663
+ return super.post(basiqUser);
13664
+ }
13665
+ retrieveJob(jobId, basiqUserId) {
13666
+ return this.basiqTokenService.getOne(basiqUserId).pipe(concatMap(token => {
13667
+ const headers = new HttpHeaders({ Authorization: 'Bearer ' + token.value });
13668
+ return this.http.get(`${BasiqUserService.basiqApiUrl}/jobs/${jobId}`, { headers })
13669
+ .pipe(map((response) => plainToClass(BasiqJobResponse, response)));
13670
+ }));
13671
+ }
13672
+ /**
13673
+ * Open basiq consent ui to allow user to log in to bank
13674
+ */
13675
+ redirectToBasiqConsent(bankId, basiqUserId) {
13676
+ const user$ = basiqUserId ? this.findBy('id', basiqUserId) : this.post();
13677
+ return user$.pipe(filter(user => !!user), concatMap(user => this.basiqTokenService.getOne(user.id).pipe(map(token => ({ user, token: token })))), map(({ user, token }) => {
13678
+ const url = new URL(BasiqUserService.basiqConsentUrl);
13679
+ url.searchParams.set('token', token.value);
13680
+ url.searchParams.set('institutionId', bankId);
13681
+ // @TODO TT-4883 vik state not coming from basiq
13682
+ localStorage.setItem('basiqUserId', user.id);
13683
+ // url.searchParams.set('state', user.id);
13684
+ if (user.consentId) {
13685
+ url.searchParams.set('action', 'connect');
13686
+ }
13687
+ window.location.replace(url.toString());
13688
+ }));
13689
+ }
13690
+ /**
13691
+ * redirect to basiq extend consent date to prolong it
13692
+ */
13693
+ extendConsent(basiqUserId) {
13694
+ return this.basiqTokenService.getOne(basiqUserId).pipe(map(token => {
13695
+ window.location.replace(`${BasiqUserService.basiqConsentUrl}?token=${token.value}&action=extend`);
13696
+ }));
13697
+ }
13698
+ /**
13699
+ * redirect to basiq extend connection date to prolong it
13700
+ */
13701
+ reauthoriseConnection(connection) {
13702
+ return this.basiqTokenService.getOne(connection.basiqUser.id).pipe(map(token => {
13703
+ let url = `${BasiqUserService.basiqConsentUrl}?token=${token.value}&action=reauthorise`;
13704
+ if (connection.isExpiring()) {
13705
+ url += `&connectionId=${connection.externalId}`;
13706
+ }
13707
+ window.location.replace(url);
13708
+ }));
13709
+ }
13710
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasiqUserService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
13711
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasiqUserService, providedIn: 'root' }); }
13712
+ }
13713
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasiqUserService, decorators: [{
13714
+ type: Injectable,
13715
+ args: [{
13716
+ providedIn: 'root'
13717
+ }]
13718
+ }] });
13719
+
13720
+ /**
13721
+ * Service that handling banks logic
13722
+ */
13723
+ class BankTransactionCommentService extends RestService$1 {
13724
+ constructor() {
13725
+ super(...arguments);
13726
+ this.modelClass = BankTransactionComment;
13727
+ this.collectionClass = Collection;
13728
+ this.endpointUri = 'bank-transaction-comments';
13729
+ this.disabledMethods = ['postBatch', 'putBatch', 'deleteBatch'];
13730
+ }
13731
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankTransactionCommentService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
13732
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankTransactionCommentService, providedIn: 'root' }); }
13733
+ }
13734
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankTransactionCommentService, decorators: [{
13735
+ type: Injectable,
13736
+ args: [{
13737
+ providedIn: 'root'
13738
+ }]
13739
+ }] });
13740
+
13741
+ var BankTransactionCommentMessagesEnum;
13742
+ (function (BankTransactionCommentMessagesEnum) {
13743
+ BankTransactionCommentMessagesEnum["CREATED"] = "Note created";
13744
+ BankTransactionCommentMessagesEnum["UPDATED"] = "Note updated";
13745
+ BankTransactionCommentMessagesEnum["DELETED"] = "Note deleted";
13746
+ BankTransactionCommentMessagesEnum["CONFIRM_DELETE"] = "Are you sure you want to delete this note?";
13747
+ })(BankTransactionCommentMessagesEnum || (BankTransactionCommentMessagesEnum = {}));
13748
+
13749
+ /**
13750
+ * Service that handling banks logic
13751
+ */
13752
+ class BankService extends RestService$1 {
13753
+ constructor() {
13754
+ super(...arguments);
13755
+ this.modelClass = Bank;
13756
+ this.collectionClass = Collection;
13757
+ this.endpointUri = 'banks';
13758
+ this.disabledMethods = ['post', 'postBatch', 'put', 'putBatch', 'delete', 'deleteBatch'];
13759
+ }
13760
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
13761
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankService, providedIn: 'root' }); }
13762
+ }
13763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BankService, decorators: [{
13764
+ type: Injectable,
13765
+ args: [{
13766
+ providedIn: 'root'
13767
+ }]
13768
+ }] });
13769
+
13774
13770
  class BudgetService extends RestService$1 {
13775
13771
  constructor() {
13776
13772
  super(...arguments);
@@ -22027,6 +22023,7 @@ const ENDPOINTS = {
22027
22023
  BASIQ_TOKENS_GET: new Endpoint('GET', '\\/basiq-users\\/tokens'),
22028
22024
  BASIQ_TOKEN_GET: new Endpoint('GET', '\\/basiq-users/\\d+\\/tokens'),
22029
22025
  BASIQ_DELETE: new Endpoint('PUT', '\\/bank-connections/\\d+\\/remove-basiq'),
22026
+ BASIQ_CONSENT_REVOKE: new Endpoint('PUT', '\\/basiq-users\\/\\consents\\/revoke'),
22030
22027
  BASIQ_USERS_GET: new Endpoint('GET', '\\/basiq-users'),
22031
22028
  BASIQ_USERS_POST: new Endpoint('POST', '\\/basiq-users'),
22032
22029
  BASIQ_USERS_PUT: new Endpoint('PUT', '\\/basiq-users\\/\\d+'),
@@ -24755,7 +24752,9 @@ class BasReportForm extends AbstractForm {
24755
24752
  const filteredTransactions = transactions.filterByRange('date', dateFrom, dateTo);
24756
24753
  const filteredDepreciations = depreciations.filterByRange('date', dateFrom, dateTo);
24757
24754
  const incomeTransactions = filteredTransactions.getIncomeTransactions();
24758
- const expenseTransactions = new TransactionCollection(filteredTransactions.getExpenseTransactions().toArray(), filteredDepreciations.toArray());
24755
+ const depreciationTransactions = filteredDepreciations.map(depreciation => depreciation.toTransaction({ amount: -depreciation.amount }));
24756
+ const expenseTransactions = new TransactionCollection(filteredTransactions.getExpenseTransactions().toArray());
24757
+ expenseTransactions.push(...depreciationTransactions);
24759
24758
  // all sole income claimed as 100%
24760
24759
  // @TODO temp fix, waiting for TT-3503/TT-3495 breaking changes
24761
24760
  this.patchField('income', incomeTransactions.sumBy('amountWithGst'));