taxtank-core 0.31.51 → 0.31.53

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.
Files changed (27) hide show
  1. package/esm2020/lib/collections/holding/holding-sale.collection.mjs +2 -2
  2. package/esm2020/lib/collections/report/vehicle-expense/vehicle-expense.collection.mjs +6 -6
  3. package/esm2020/lib/db/Models/abstract-model.mjs +5 -1
  4. package/esm2020/lib/models/holding/holding-sale.mjs +7 -1
  5. package/esm2020/lib/models/holding/holding-type.mjs +4 -1
  6. package/esm2020/lib/models/holding/holding.mjs +4 -1
  7. package/esm2020/lib/services/auth/auth.service.mjs +1 -2
  8. package/esm2020/lib/services/auth/jwt.service.mjs +8 -2
  9. package/esm2020/lib/services/http/facebook/facebook.service.mjs +3 -4
  10. package/esm2020/lib/services/http/google/google.service.mjs +1 -2
  11. package/esm2020/lib/services/http/tax-review/tax-review.service.mjs +2 -3
  12. package/esm2020/lib/services/http/user/user.service.mjs +6 -3
  13. package/esm2020/lib/services/mixpanel/mixpanel.service.mjs +7 -1
  14. package/fesm2015/taxtank-core.mjs +88 -61
  15. package/fesm2015/taxtank-core.mjs.map +1 -1
  16. package/fesm2020/taxtank-core.mjs +85 -59
  17. package/fesm2020/taxtank-core.mjs.map +1 -1
  18. package/lib/collections/report/vehicle-expense/vehicle-expense.collection.d.ts +1 -2
  19. package/lib/db/Models/abstract-model.d.ts +1 -0
  20. package/lib/models/holding/holding-sale.d.ts +8 -1
  21. package/lib/models/holding/holding-type.d.ts +6 -1
  22. package/lib/models/holding/holding.d.ts +6 -1
  23. package/lib/services/auth/jwt.service.d.ts +1 -0
  24. package/lib/services/http/facebook/facebook.service.d.ts +2 -2
  25. package/lib/services/http/tax-review/tax-review.service.d.ts +1 -1
  26. package/lib/services/mixpanel/mixpanel.service.d.ts +1 -0
  27. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Inject, inject, EventEmitter, NgModule, Pipe } from '@angular/core';
3
3
  import * as i1$1 from '@angular/common';
4
- import { CommonModule, CurrencyPipe, DatePipe } from '@angular/common';
4
+ import { formatDate, CommonModule, CurrencyPipe, DatePipe } from '@angular/common';
5
5
  import * as i1 from '@angular/common/http';
6
6
  import { HttpParams, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
7
7
  import { map, mergeMap, filter, first as first$1, catchError, skip, take, switchMap, finalize, debounceTime, distinctUntilChanged, delay } from 'rxjs/operators';
@@ -172,6 +172,9 @@ class AbstractModel {
172
172
  hasValue(value, path = 'id') {
173
173
  return get(path) === value;
174
174
  }
175
+ formatDate(date, format = 'MMM d, y') {
176
+ return formatDate(date, format, 'en-AU');
177
+ }
175
178
  }
176
179
 
177
180
  let Country$1 = class Country extends AbstractModel {
@@ -8223,16 +8226,17 @@ class VehicleExpense extends AbstractModel {
8223
8226
  }
8224
8227
 
8225
8228
  class VehicleExpenseCollection extends Collection {
8226
- constructor(transactions, depreciations, vehicleClaim) {
8229
+ constructor(transactions, depreciations) {
8227
8230
  super();
8228
- this.setItems(transactions, depreciations, vehicleClaim);
8231
+ this.setItems(transactions, depreciations);
8229
8232
  }
8230
- setItems(transactions, depreciations, vehicleClaim) {
8233
+ setItems(transactions, depreciations) {
8234
+ var _a, _b;
8231
8235
  this.items = [];
8232
8236
  const transactionsByChartAccounts = transactions.groupBy('chartAccounts.name');
8233
- const transactionExpenses = transactionsByChartAccounts.keys.map((chartAccountsName) => new VehicleExpense(transactionsByChartAccounts.get(chartAccountsName).amount, vehicleClaim.workUsage, chartAccountsName));
8237
+ const transactionExpenses = transactionsByChartAccounts.keys.map((chartAccountsName) => new VehicleExpense(transactionsByChartAccounts.get(chartAccountsName).amount, transactionsByChartAccounts.get(chartAccountsName).first.claimPercent, chartAccountsName));
8234
8238
  // group all depreciations into one expense item
8235
- const depreciationExpense = new VehicleExpense(-depreciations.getCurrentYearForecastAmount(), vehicleClaim.workUsage, 'Depreciation');
8239
+ const depreciationExpense = new VehicleExpense(-depreciations.getCurrentYearForecastAmount(), (_b = (_a = depreciations.first) === null || _a === void 0 ? void 0 : _a.claimPercent) !== null && _b !== void 0 ? _b : 0, 'Depreciation');
8236
8240
  this.items.push(...[depreciationExpense, ...transactionExpenses]);
8237
8241
  }
8238
8242
  }
@@ -9341,7 +9345,7 @@ class HoldingSaleCollection extends ExportableCollection {
9341
9345
  plainToClass(ExportCell, { value: sale.totalCapitalGain, type: ExportCellTypeEnum.CURRENCY }),
9342
9346
  plainToClass(ExportCell, { value: sale.grossCapitalGain, type: ExportCellTypeEnum.CURRENCY }),
9343
9347
  plainToClass(ExportCell, {
9344
- value: sale.isOneYearExemptionApplicable() ? '50% (1 year rule)' : 'None',
9348
+ value: sale.concession,
9345
9349
  type: ExportCellTypeEnum.STRING
9346
9350
  }),
9347
9351
  ];
@@ -10206,6 +10210,9 @@ class HoldingType extends AbstractModel {
10206
10210
  isCrypto() {
10207
10211
  return this.category === HoldingTypeCategoryEnum.CRYPTO;
10208
10212
  }
10213
+ getMpData() {
10214
+ return { category: HoldingTypeCategoryEnum[this.category], name: this.name };
10215
+ }
10209
10216
  }
10210
10217
  __decorate([
10211
10218
  Type(() => AppFile)
@@ -10230,6 +10237,9 @@ class HoldingSale extends AssetSale {
10230
10237
  isOneYearExemptionApplicable() {
10231
10238
  return this.grossCapitalGain !== this.netCapitalGain;
10232
10239
  }
10240
+ get concession() {
10241
+ return this.isOneYearExemptionApplicable() ? '50% (1 year rule)' : 'None';
10242
+ }
10233
10243
  getCostBase(holding) {
10234
10244
  return this.getPurchasePrice(holding) + holding.fee;
10235
10245
  }
@@ -10245,6 +10255,9 @@ class HoldingSale extends AssetSale {
10245
10255
  get cost() {
10246
10256
  return this.price * this.quantity;
10247
10257
  }
10258
+ getMpData(type) {
10259
+ return { holding: type.name, concession: this.concession };
10260
+ }
10248
10261
  }
10249
10262
  __decorate([
10250
10263
  Transform(({ value }) => ({ id: value.id }), { toPlainOnly: true })
@@ -10289,6 +10302,9 @@ class Holding extends AbstractModel {
10289
10302
  isSold() {
10290
10303
  return this.currentQuantity === 0;
10291
10304
  }
10305
+ getMpData() {
10306
+ return { type: this.type.name, date: this.formatDate(this.date) };
10307
+ }
10292
10308
  }
10293
10309
  __decorate([
10294
10310
  Type(() => Date)
@@ -10541,6 +10557,12 @@ class MixpanelService {
10541
10557
  }
10542
10558
  mixpanel.track(event, properties);
10543
10559
  }
10560
+ trackPageView() {
10561
+ if (!this.environment.enableMixpanel) {
10562
+ return;
10563
+ }
10564
+ mixpanel['track_pageview']();
10565
+ }
10544
10566
  }
10545
10567
  MixpanelService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: MixpanelService, deps: [{ token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
10546
10568
  MixpanelService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: MixpanelService, providedIn: 'root' });
@@ -10596,6 +10618,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
10596
10618
  const NAME_TOKEN = 'token';
10597
10619
  const NAME_REFRESH_TOKEN = 'refreshToken';
10598
10620
  class JwtService extends JwtHelperService {
10621
+ constructor() {
10622
+ super(...arguments);
10623
+ this.mpService = inject(MixpanelService);
10624
+ }
10599
10625
  getToken() {
10600
10626
  return localStorage[NAME_TOKEN];
10601
10627
  }
@@ -10605,6 +10631,7 @@ class JwtService extends JwtHelperService {
10605
10631
  saveTokens(tokens) {
10606
10632
  localStorage[NAME_TOKEN] = tokens.token;
10607
10633
  localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;
10634
+ this.mpService.identify(this.getUser().id);
10608
10635
  }
10609
10636
  destroyTokens() {
10610
10637
  localStorage.removeItem(NAME_TOKEN);
@@ -11971,6 +11998,55 @@ var DocumentMessagesEnum;
11971
11998
  DocumentMessagesEnum["DELETED"] = "Document deleted!";
11972
11999
  })(DocumentMessagesEnum || (DocumentMessagesEnum = {}));
11973
12000
 
12001
+ class AuthService {
12002
+ constructor(http, jwtService, mpService, environment) {
12003
+ this.http = http;
12004
+ this.jwtService = jwtService;
12005
+ this.mpService = mpService;
12006
+ this.environment = environment;
12007
+ this.isLoggedInSubject = new BehaviorSubject(!this.jwtService.isTokenExpired());
12008
+ }
12009
+ setAuth(response) {
12010
+ this.jwtService.saveTokens(response);
12011
+ this.isLoggedInSubject.next(true);
12012
+ }
12013
+ login(username, password) {
12014
+ return this.http.post(`${this.environment.apiV2}/login`, { username, password }).pipe(map((response) => {
12015
+ this.setAuth(response);
12016
+ this.mpService.track('login');
12017
+ return response;
12018
+ }), catchError((error) => {
12019
+ this.mpService.track('loginError', { username });
12020
+ return throwError(error);
12021
+ }));
12022
+ }
12023
+ refresh(refreshToken) {
12024
+ return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(map((response) => {
12025
+ this.setAuth(response);
12026
+ return response;
12027
+ }));
12028
+ }
12029
+ logoutFront(url = '/login') {
12030
+ localStorage.clear();
12031
+ this.mpService.track('logout');
12032
+ this.mpService.reset();
12033
+ location.replace(url);
12034
+ }
12035
+ }
12036
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: JwtService }, { token: MixpanelService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
12037
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, providedIn: 'root' });
12038
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, decorators: [{
12039
+ type: Injectable,
12040
+ args: [{
12041
+ providedIn: 'root'
12042
+ }]
12043
+ }], ctorParameters: function () {
12044
+ return [{ type: i1.HttpClient }, { type: JwtService }, { type: MixpanelService }, { type: undefined, decorators: [{
12045
+ type: Inject,
12046
+ args: ['environment']
12047
+ }] }];
12048
+ } });
12049
+
11974
12050
  const ERROR_EMAIL_PERMISSION = 'Access to email denied. Please provide access to email in facebook.';
11975
12051
  class FacebookService {
11976
12052
  /**
@@ -12006,7 +12082,6 @@ class FacebookService {
12006
12082
  setAuth(response) {
12007
12083
  this.jwtService.saveTokens(response);
12008
12084
  this.isLoggedInSubject.next(true);
12009
- this.mpService.identify(this.jwtService.getUser().id);
12010
12085
  this.mpService.track('loginFB');
12011
12086
  }
12012
12087
  /**
@@ -12058,56 +12133,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
12058
12133
  }] }];
12059
12134
  } });
12060
12135
 
12061
- class AuthService {
12062
- constructor(http, jwtService, mpService, environment) {
12063
- this.http = http;
12064
- this.jwtService = jwtService;
12065
- this.mpService = mpService;
12066
- this.environment = environment;
12067
- this.isLoggedInSubject = new BehaviorSubject(!this.jwtService.isTokenExpired());
12068
- }
12069
- setAuth(response) {
12070
- this.jwtService.saveTokens(response);
12071
- this.isLoggedInSubject.next(true);
12072
- }
12073
- login(username, password) {
12074
- return this.http.post(`${this.environment.apiV2}/login`, { username, password }).pipe(map((response) => {
12075
- this.setAuth(response);
12076
- this.mpService.identify(this.jwtService.getUser().id);
12077
- this.mpService.track('login');
12078
- return response;
12079
- }), catchError((error) => {
12080
- this.mpService.track('loginError', { username });
12081
- return throwError(error);
12082
- }));
12083
- }
12084
- refresh(refreshToken) {
12085
- return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(map((response) => {
12086
- this.setAuth(response);
12087
- return response;
12088
- }));
12089
- }
12090
- logoutFront(url = '/login') {
12091
- localStorage.clear();
12092
- this.mpService.track('logout');
12093
- this.mpService.reset();
12094
- location.replace(url);
12095
- }
12096
- }
12097
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: JwtService }, { token: MixpanelService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
12098
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, providedIn: 'root' });
12099
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, decorators: [{
12100
- type: Injectable,
12101
- args: [{
12102
- providedIn: 'root'
12103
- }]
12104
- }], ctorParameters: function () {
12105
- return [{ type: i1.HttpClient }, { type: JwtService }, { type: MixpanelService }, { type: undefined, decorators: [{
12106
- type: Inject,
12107
- args: ['environment']
12108
- }] }];
12109
- } });
12110
-
12111
12136
  /**
12112
12137
  * Google instance
12113
12138
  * https://developers.google.com/identity/oauth2/web/guides/overview
@@ -12152,7 +12177,6 @@ class GoogleService {
12152
12177
  .subscribe((response) => {
12153
12178
  this.jwtService.saveTokens(response);
12154
12179
  this.isLoggedInSubject.next(true);
12155
- this.mpService.identify(this.jwtService.getUser().id);
12156
12180
  this.mpService.track('loginGoogle');
12157
12181
  this.router.navigate([redirectUrl]);
12158
12182
  }, (error) => {
@@ -15663,12 +15687,15 @@ class UserService extends RestService$1 {
15663
15687
  localStorage.setItem('userId', this.getCacheFirst().id.toString());
15664
15688
  localStorage.setItem('financialYear', this.getCacheFirst().financialYear.toString());
15665
15689
  localStorage.setItem('roles', JSON.stringify(this.getCacheFirst().roles));
15666
- this.mpService.identify(this.getCacheFirst().id);
15667
15690
  return users;
15668
15691
  }));
15669
15692
  }
15670
15693
  register(data) {
15671
- return this.http.post(`${this.apiUrl}/registration`, data);
15694
+ return this.http.post(`${this.apiUrl}/registration`, data)
15695
+ .pipe(map((user) => {
15696
+ this.mpService.identify(user['id']);
15697
+ return user;
15698
+ }));
15672
15699
  }
15673
15700
  changePassword(currentPassword, newPassword) {
15674
15701
  return this.http.put(`${this.apiUrl}/password/change`, { currentPassword, newPassword })