taxtank-core 0.8.7 → 0.9.2

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.
@@ -1807,13 +1807,6 @@
1807
1807
  enumerable: false,
1808
1808
  configurable: true
1809
1809
  });
1810
- /**
1811
- * Get new collection of transactions filtered by tank type
1812
- * @param tankType
1813
- */
1814
- TransactionCollection.prototype.getByTankType = function (tankType) {
1815
- return new TransactionCollection(this.items.filter(function (transaction) { return transaction.tankType === tankType; }));
1816
- };
1817
1810
  /**
1818
1811
  * get date of the last transaction
1819
1812
  */
@@ -2895,12 +2888,17 @@
2895
2888
  ChartAccountsCategoryEnum[ChartAccountsCategoryEnum["SOLE_DEPRECIATION"] = 14] = "SOLE_DEPRECIATION";
2896
2889
  })(exports.ChartAccountsCategoryEnum || (exports.ChartAccountsCategoryEnum = {}));
2897
2890
 
2891
+ /**
2892
+ * Grouped chart accounts categories for fast work
2893
+ * @TODO Alex: Clean up and/or remove some groups
2894
+ */
2898
2895
  var CHART_ACCOUNTS_CATEGORIES = {
2899
2896
  income: [
2900
2897
  exports.ChartAccountsCategoryEnum.PROPERTY_INCOME,
2901
2898
  exports.ChartAccountsCategoryEnum.WORK_INCOME,
2902
2899
  exports.ChartAccountsCategoryEnum.OTHER_INCOME,
2903
- exports.ChartAccountsCategoryEnum.PERSONAL_INCOME
2900
+ exports.ChartAccountsCategoryEnum.PERSONAL_INCOME,
2901
+ exports.ChartAccountsCategoryEnum.SOLE_INCOME,
2904
2902
  ],
2905
2903
  expense: [
2906
2904
  exports.ChartAccountsCategoryEnum.PROPERTY_EXPENSE,
@@ -2909,7 +2907,9 @@
2909
2907
  exports.ChartAccountsCategoryEnum.WORK_DEPRECIATION,
2910
2908
  exports.ChartAccountsCategoryEnum.WORK_EXPENSE,
2911
2909
  exports.ChartAccountsCategoryEnum.OTHER_EXPENSE,
2912
- exports.ChartAccountsCategoryEnum.PERSONAL_EXPENSE
2910
+ exports.ChartAccountsCategoryEnum.PERSONAL_EXPENSE,
2911
+ exports.ChartAccountsCategoryEnum.SOLE_EXPENSE,
2912
+ exports.ChartAccountsCategoryEnum.SOLE_DEPRECIATION
2913
2913
  ],
2914
2914
  property: [
2915
2915
  exports.ChartAccountsCategoryEnum.PROPERTY_EXPENSE,
@@ -2924,6 +2924,11 @@
2924
2924
  exports.ChartAccountsCategoryEnum.OTHER_EXPENSE,
2925
2925
  exports.ChartAccountsCategoryEnum.OTHER_INCOME
2926
2926
  ],
2927
+ sole: [
2928
+ exports.ChartAccountsCategoryEnum.SOLE_INCOME,
2929
+ exports.ChartAccountsCategoryEnum.SOLE_EXPENSE,
2930
+ exports.ChartAccountsCategoryEnum.SOLE_DEPRECIATION
2931
+ ],
2927
2932
  personal: [
2928
2933
  exports.ChartAccountsCategoryEnum.PERSONAL_EXPENSE,
2929
2934
  exports.ChartAccountsCategoryEnum.PERSONAL_INCOME
@@ -2946,6 +2951,15 @@
2946
2951
  // @TODO Alex why?
2947
2952
  exports.ChartAccountsCategoryEnum.PERSONAL_INCOME
2948
2953
  ],
2954
+ soleExpense: [
2955
+ exports.ChartAccountsCategoryEnum.SOLE_EXPENSE,
2956
+ ],
2957
+ soleIncome: [
2958
+ exports.ChartAccountsCategoryEnum.SOLE_INCOME,
2959
+ ],
2960
+ soleDepreciation: [
2961
+ exports.ChartAccountsCategoryEnum.SOLE_DEPRECIATION,
2962
+ ],
2949
2963
  workTankHeader: [
2950
2964
  exports.ChartAccountsCategoryEnum.WORK_INCOME,
2951
2965
  exports.ChartAccountsCategoryEnum.OTHER_INCOME,
@@ -2986,17 +3000,22 @@
2986
3000
  * Check if current tank is Property
2987
3001
  */
2988
3002
  TransactionBase.prototype.isPropertyTank = function () {
2989
- return !!this.property;
3003
+ var _a;
3004
+ return CHART_ACCOUNTS_CATEGORIES.property.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
2990
3005
  };
2991
3006
  /**
2992
3007
  * Check if current tank is Work
2993
3008
  */
2994
3009
  TransactionBase.prototype.isWorkTank = function () {
2995
- // @TODO remove this hack
2996
- if (this.tankType) {
2997
- return this.tankType === exports.TankTypeEnum.WORK;
2998
- }
2999
- return CHART_ACCOUNTS_CATEGORIES.work.includes(this.chartAccounts.category);
3010
+ var _a;
3011
+ return CHART_ACCOUNTS_CATEGORIES.work.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
3012
+ };
3013
+ /**
3014
+ * Check if current tank is Sole
3015
+ */
3016
+ TransactionBase.prototype.isSoleTank = function () {
3017
+ var _a;
3018
+ return CHART_ACCOUNTS_CATEGORIES.sole.includes((_a = this.chartAccounts) === null || _a === void 0 ? void 0 : _a.category);
3000
3019
  };
3001
3020
  return TransactionBase;
3002
3021
  }());
@@ -5219,6 +5238,10 @@
5219
5238
  return [exports.ChartAccountsCategoryEnum.WORK_EXPENSE, exports.ChartAccountsCategoryEnum.OTHER_EXPENSE, exports.ChartAccountsCategoryEnum.WORK_DEPRECIATION]
5220
5239
  .includes(this.category);
5221
5240
  };
5241
+ ChartAccounts.prototype.isSoleExpense = function () {
5242
+ return [exports.ChartAccountsCategoryEnum.SOLE_EXPENSE, exports.ChartAccountsCategoryEnum.SOLE_DEPRECIATION]
5243
+ .includes(this.category);
5244
+ };
5222
5245
  /**
5223
5246
  * Check if chart accounts is property expense
5224
5247
  */
@@ -5788,7 +5811,7 @@
5788
5811
  return CHART_ACCOUNTS_CATEGORIES.expense.includes(this.chartAccounts.category);
5789
5812
  };
5790
5813
  Transaction.prototype.isPersonal = function () {
5791
- return !this.tankType;
5814
+ return CHART_ACCOUNTS_CATEGORIES.personal.includes(this.chartAccounts.category);
5792
5815
  };
5793
5816
  Object.defineProperty(Transaction.prototype, "chartAccountsCategories", {
5794
5817
  get: function () {
@@ -5797,6 +5820,8 @@
5797
5820
  return CHART_ACCOUNTS_CATEGORIES.personal;
5798
5821
  case this.isPropertyTank():
5799
5822
  return CHART_ACCOUNTS_CATEGORIES.property;
5823
+ case this.isSoleTank():
5824
+ return CHART_ACCOUNTS_CATEGORIES.sole;
5800
5825
  default:
5801
5826
  return CHART_ACCOUNTS_CATEGORIES.work;
5802
5827
  }
@@ -7963,6 +7988,24 @@
7963
7988
  TaxSummaryTypeEnum["FORECASTS"] = "forecasts";
7964
7989
  })(exports.TaxSummaryTypeEnum || (exports.TaxSummaryTypeEnum = {}));
7965
7990
 
7991
+ /**
7992
+ * Common toast message class
7993
+ */
7994
+ var Toast = /** @class */ (function () {
7995
+ function Toast() {
7996
+ this.duration = 3000;
7997
+ }
7998
+ return Toast;
7999
+ }());
8000
+
8001
+ exports.ToastTypeEnum = void 0;
8002
+ (function (ToastTypeEnum) {
8003
+ ToastTypeEnum[ToastTypeEnum["INFO"] = 0] = "INFO";
8004
+ ToastTypeEnum[ToastTypeEnum["SUCCESS"] = 1] = "SUCCESS";
8005
+ ToastTypeEnum[ToastTypeEnum["WARNING"] = 2] = "WARNING";
8006
+ ToastTypeEnum[ToastTypeEnum["ERROR"] = 3] = "ERROR";
8007
+ })(exports.ToastTypeEnum || (exports.ToastTypeEnum = {}));
8008
+
7966
8009
  var MyAccountHistory = /** @class */ (function () {
7967
8010
  function MyAccountHistory() {
7968
8011
  }
@@ -11769,6 +11812,58 @@
11769
11812
  }] }];
11770
11813
  } });
11771
11814
 
11815
+ /**
11816
+ * popup notifications service (toast, snackbar).
11817
+ */
11818
+ var ToastService = /** @class */ (function () {
11819
+ function ToastService() {
11820
+ this.toast$ = new rxjs.ReplaySubject(1);
11821
+ }
11822
+ ToastService.prototype.get = function () {
11823
+ return this.toast$.asObservable();
11824
+ };
11825
+ ToastService.prototype.add = function (toast) {
11826
+ this.toast$.next(toast);
11827
+ };
11828
+ ToastService.prototype.success = function (message) {
11829
+ this.add(classTransformer.plainToClass(Toast, {
11830
+ type: exports.ToastTypeEnum.SUCCESS,
11831
+ title: 'Success!',
11832
+ message: message,
11833
+ }));
11834
+ };
11835
+ ToastService.prototype.warning = function (message) {
11836
+ this.add(classTransformer.plainToClass(Toast, {
11837
+ type: exports.ToastTypeEnum.WARNING,
11838
+ title: 'Warning!',
11839
+ message: message,
11840
+ }));
11841
+ };
11842
+ ToastService.prototype.error = function (message) {
11843
+ this.add(classTransformer.plainToClass(Toast, {
11844
+ type: exports.ToastTypeEnum.ERROR,
11845
+ title: 'Error!',
11846
+ message: message,
11847
+ }));
11848
+ };
11849
+ ToastService.prototype.info = function (message) {
11850
+ this.add(classTransformer.plainToClass(Toast, {
11851
+ type: exports.ToastTypeEnum.INFO,
11852
+ title: 'Information',
11853
+ message: message,
11854
+ }));
11855
+ };
11856
+ return ToastService;
11857
+ }());
11858
+ ToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11859
+ ToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, providedIn: 'root' });
11860
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, decorators: [{
11861
+ type: i0.Injectable,
11862
+ args: [{
11863
+ providedIn: 'root'
11864
+ }]
11865
+ }] });
11866
+
11772
11867
  function enumToList(data) {
11773
11868
  var list = [];
11774
11869
  for (var key in data) {
@@ -11782,16 +11877,24 @@
11782
11877
  return list;
11783
11878
  }
11784
11879
 
11880
+ var MessagesEnum;
11881
+ (function (MessagesEnum) {
11882
+ MessagesEnum["DELETED_MESSAGE"] = "Transaction deleted";
11883
+ MessagesEnum["UPDATED_MESSAGE"] = "Transaction updated";
11884
+ MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
11885
+ })(MessagesEnum || (MessagesEnum = {}));
11886
+
11785
11887
  /**
11786
11888
  * Service for transactions business logic
11787
11889
  */
11788
11890
  var TransactionService = /** @class */ (function (_super) {
11789
11891
  __extends(TransactionService, _super);
11790
- function TransactionService(http, eventDispatcherService, environment) {
11892
+ function TransactionService(http, eventDispatcherService, environment, toastService) {
11791
11893
  var _this = _super.call(this, http, eventDispatcherService, environment) || this;
11792
11894
  _this.http = http;
11793
11895
  _this.eventDispatcherService = eventDispatcherService;
11794
11896
  _this.environment = environment;
11897
+ _this.toastService = toastService;
11795
11898
  // url part for Transaction API
11796
11899
  _this.url = 'transactions';
11797
11900
  _this.modelClass = Transaction;
@@ -11804,6 +11907,7 @@
11804
11907
  */
11805
11908
  TransactionService.prototype.listenEvents = function () {
11806
11909
  this.listenDepreciationChange();
11910
+ this.listenPropertyShareUpdate();
11807
11911
  };
11808
11912
  /**
11809
11913
  * get list of all user's TaxTank transactions
@@ -11912,6 +12016,7 @@
11912
12016
  _this.updateCache();
11913
12017
  }
11914
12018
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTIONS_CREATED, addedTransactions));
12019
+ _this.toastService.success(MessagesEnum.CREATED_MESSAGE);
11915
12020
  return addedTransactions;
11916
12021
  }));
11917
12022
  };
@@ -11948,6 +12053,7 @@
11948
12053
  _this.addBatch(childTransactionsToAdd).subscribe();
11949
12054
  }
11950
12055
  }
12056
+ _this.toastService.success(MessagesEnum.UPDATED_MESSAGE);
11951
12057
  replace(_this.cache, updatedTransaction);
11952
12058
  _this.updateCache();
11953
12059
  return updatedTransaction;
@@ -11996,6 +12102,7 @@
11996
12102
  return transaction.id !== model.id && ((_a = transaction.parentTransaction) === null || _a === void 0 ? void 0 : _a.id) !== model.id;
11997
12103
  });
11998
12104
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_DELETED, model));
12105
+ _this.toastService.success(MessagesEnum.DELETED_MESSAGE);
11999
12106
  _this.updateCache();
12000
12107
  _this.transactionDeleted.emit(model);
12001
12108
  }));
@@ -12080,9 +12187,16 @@
12080
12187
  });
12081
12188
  });
12082
12189
  };
12190
+ /**
12191
+ * Listen to EventDispatcherService event related to Property Share changing
12192
+ */
12193
+ TransactionService.prototype.listenPropertyShareUpdate = function () {
12194
+ var _this = this;
12195
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(function () { return _this.resetCache(); });
12196
+ };
12083
12197
  return TransactionService;
12084
12198
  }(RestService));
12085
- TransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12199
+ TransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12086
12200
  TransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, providedIn: 'root' });
12087
12201
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, decorators: [{
12088
12202
  type: i0.Injectable,
@@ -12093,7 +12207,7 @@
12093
12207
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12094
12208
  type: i0.Inject,
12095
12209
  args: ['environment']
12096
- }] }];
12210
+ }] }, { type: ToastService }];
12097
12211
  } });
12098
12212
 
12099
12213
  // @TODO Don't look at the commented code. Will be refactored/removed during TT-1503
@@ -13137,6 +13251,8 @@
13137
13251
  exports.TaxSummary = TaxSummary;
13138
13252
  exports.TaxSummarySection = TaxSummarySection;
13139
13253
  exports.TaxSummaryService = TaxSummaryService;
13254
+ exports.Toast = Toast;
13255
+ exports.ToastService = ToastService;
13140
13256
  exports.Transaction = Transaction;
13141
13257
  exports.TransactionAllocation = TransactionAllocation;
13142
13258
  exports.TransactionAllocationCollection = TransactionAllocationCollection;