taxtank-core 0.10.6 → 0.12.0

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 (162) hide show
  1. package/bundles/taxtank-core.umd.js +1723 -1351
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/account-setup-item.collection.js +11 -0
  4. package/esm2015/lib/collections/bank-transaction.collection.js +2 -2
  5. package/esm2015/lib/collections/collection-dictionary.js +4 -4
  6. package/esm2015/lib/collections/collection.js +4 -1
  7. package/esm2015/lib/collections/depreciation.collection.js +24 -10
  8. package/esm2015/lib/collections/transaction-allocation.collection.js +2 -2
  9. package/esm2015/lib/collections/transaction.collection.js +28 -1
  10. package/esm2015/lib/collections/vehicle-logbook.collection.js +88 -0
  11. package/esm2015/lib/collections/vehicle.collection.js +9 -0
  12. package/esm2015/lib/db/Enums/chart-accounts-heading-vehicle-list.enum.js +3 -1
  13. package/esm2015/lib/db/Enums/chart-accounts-list.enum.js +4 -3
  14. package/esm2015/lib/db/Enums/property/property-category-list.enum.js +2 -1
  15. package/esm2015/lib/db/Enums/user-status.enum.js +1 -2
  16. package/esm2015/lib/db/Models/client-details.js +1 -1
  17. package/esm2015/lib/db/Models/client-income-types.js +3 -0
  18. package/esm2015/lib/db/Models/vehicle-claim.js +1 -1
  19. package/esm2015/lib/db/Models/vehicle.js +1 -1
  20. package/esm2015/lib/forms/client/client-income-types.form.js +22 -0
  21. package/esm2015/lib/forms/index.js +4 -1
  22. package/esm2015/lib/forms/vehicle/vehicle-claim.form.js +114 -0
  23. package/esm2015/lib/forms/vehicle/vehicle.form.js +20 -0
  24. package/esm2015/lib/interfaces/event-listener.interface.js +1 -1
  25. package/esm2015/lib/interfaces/expense.interface.js +2 -0
  26. package/esm2015/lib/interfaces/tank.interface.js +1 -1
  27. package/esm2015/lib/models/account-setup/account-setup-item.js +6 -0
  28. package/esm2015/lib/models/account-setup/account-setup-items.const.js +44 -0
  29. package/esm2015/lib/models/account-setup/account-setup-items.enum.js +14 -0
  30. package/esm2015/lib/models/chart-accounts/chart-accounts-value.js +4 -0
  31. package/esm2015/lib/models/chart-accounts/chart-accounts.js +34 -1
  32. package/esm2015/lib/models/client/client-income-types.js +10 -0
  33. package/esm2015/lib/models/depreciation/depreciation.js +5 -1
  34. package/esm2015/lib/models/event/app-event-type.enum.js +4 -1
  35. package/esm2015/lib/models/export/export-data-table.js +6 -0
  36. package/esm2015/lib/models/logbook/logbook-period.js +8 -1
  37. package/esm2015/lib/models/logbook/vehicle-claim.js +63 -4
  38. package/esm2015/lib/models/logbook/vehicle-logbook.js +9 -3
  39. package/esm2015/lib/models/logbook/vehicle.js +7 -29
  40. package/esm2015/lib/models/pdf/pdf-config.js +2 -2
  41. package/esm2015/lib/models/pdf/pdf-orientation.enum.js +6 -0
  42. package/esm2015/lib/models/transaction/transaction.js +1 -1
  43. package/esm2015/lib/services/account-setup/account-setup.service.js +109 -0
  44. package/esm2015/lib/services/http/bank/bank-account/bank-account.service.js +6 -15
  45. package/esm2015/lib/services/http/bank/bank-connection/bank-connection.service.js +6 -15
  46. package/esm2015/lib/services/http/bank/bank-transaction/bank-transaction.service.js +6 -15
  47. package/esm2015/lib/services/http/bank/basiq/basiq.service.js +6 -15
  48. package/esm2015/lib/services/http/chart-accounts/chart-accounts.service.js +1 -1
  49. package/esm2015/lib/services/http/chat/chat.service.js +8 -12
  50. package/esm2015/lib/services/http/chat/message/message.service.js +8 -12
  51. package/esm2015/lib/services/http/chat/message-document/message-document.service.js +1 -1
  52. package/esm2015/lib/services/http/depreciation/depreciation.service.js +6 -23
  53. package/esm2015/lib/services/http/document/document-folder/document-folder.service.js +6 -14
  54. package/esm2015/lib/services/http/firm/client-income/client-income-types.service.js +50 -0
  55. package/esm2015/lib/services/http/firm/client-movement/client-movement.service.js +6 -15
  56. package/esm2015/lib/services/http/income-source/income-source-forecast/income-source-forecast.service.js +6 -15
  57. package/esm2015/lib/services/http/income-source/income-source.service.js +6 -14
  58. package/esm2015/lib/services/http/income-source/salary-forecast/salary-forecast.service.js +6 -15
  59. package/esm2015/lib/services/http/income-source/sole-forecast/sole-forecast.service.js +6 -15
  60. package/esm2015/lib/services/http/loan/loan.service.js +6 -15
  61. package/esm2015/lib/services/http/property/property-document/property-document.service.js +6 -15
  62. package/esm2015/lib/services/http/property/property-share/property-share.service.js +6 -15
  63. package/esm2015/lib/services/http/property/property.service.js +6 -15
  64. package/esm2015/lib/services/http/rest/rest.service.js +31 -4
  65. package/esm2015/lib/services/http/service-notification/service-notification.service.js +8 -12
  66. package/esm2015/lib/services/http/subscription/subscription.service.js +1 -4
  67. package/esm2015/lib/services/http/tax-review/tax-review-history/tax-review-history.service.js +15 -16
  68. package/esm2015/lib/services/http/tax-review/tax-review.service.js +6 -15
  69. package/esm2015/lib/services/http/tax-summary/tax-summary.service.js +1 -1
  70. package/esm2015/lib/services/http/transaction/transaction-allocation/transaction-allocation.service.js +6 -15
  71. package/esm2015/lib/services/http/transaction/transaction.service.js +16 -25
  72. package/esm2015/lib/services/http/user/user-event-setting/user-event-setting.service.js +6 -14
  73. package/esm2015/lib/services/http/user/user-event-type/user-event-type.service.js +6 -14
  74. package/esm2015/lib/services/http/vehicle/messages.enum.js +13 -0
  75. package/esm2015/lib/services/http/vehicle/vehicle-claim.service.js +24 -0
  76. package/esm2015/lib/services/http/vehicle/vehicle-logbook.service.js +59 -0
  77. package/esm2015/lib/services/http/vehicle/vehicle.service.js +49 -213
  78. package/esm2015/lib/services/pdf/pdf.service.js +51 -26
  79. package/esm2015/lib/services/property/property-holding-costs/property-holding-costs.service.js +53 -0
  80. package/esm2015/lib/validators/at-least-one.validator.js +11 -0
  81. package/esm2015/lib/validators/index.js +2 -0
  82. package/esm2015/public-api.js +16 -2
  83. package/fesm2015/taxtank-core.js +1536 -1155
  84. package/fesm2015/taxtank-core.js.map +1 -1
  85. package/lib/collections/account-setup-item.collection.d.ts +6 -0
  86. package/lib/collections/collection.d.ts +1 -0
  87. package/lib/collections/depreciation.collection.d.ts +5 -4
  88. package/lib/collections/transaction.collection.d.ts +9 -0
  89. package/lib/collections/vehicle-logbook.collection.d.ts +30 -0
  90. package/lib/collections/vehicle.collection.d.ts +6 -0
  91. package/lib/db/Enums/chart-accounts-heading-vehicle-list.enum.d.ts +3 -1
  92. package/lib/db/Enums/chart-accounts-list.enum.d.ts +4 -3
  93. package/lib/db/Enums/property/property-category-list.enum.d.ts +2 -1
  94. package/lib/db/Enums/user-status.enum.d.ts +1 -2
  95. package/lib/db/Models/client-details.d.ts +5 -1
  96. package/lib/db/Models/client-income-types.d.ts +11 -0
  97. package/lib/db/Models/vehicle-claim.d.ts +2 -0
  98. package/lib/db/Models/vehicle.d.ts +2 -0
  99. package/lib/forms/client/client-income-types.form.d.ts +7 -0
  100. package/lib/forms/index.d.ts +3 -0
  101. package/lib/forms/vehicle/vehicle-claim.form.d.ts +43 -0
  102. package/lib/forms/vehicle/vehicle.form.d.ts +11 -0
  103. package/lib/interfaces/event-listener.interface.d.ts +1 -0
  104. package/lib/interfaces/expense.interface.d.ts +12 -0
  105. package/lib/interfaces/tank.interface.d.ts +2 -0
  106. package/lib/models/account-setup/account-setup-item.d.ts +9 -0
  107. package/lib/models/account-setup/account-setup-items.const.d.ts +7 -0
  108. package/lib/models/account-setup/account-setup-items.enum.d.ts +12 -0
  109. package/lib/models/chart-accounts/chart-accounts-value.d.ts +3 -0
  110. package/lib/models/chart-accounts/chart-accounts.d.ts +18 -0
  111. package/lib/models/client/client-income-types.d.ts +7 -0
  112. package/lib/models/depreciation/depreciation.d.ts +6 -2
  113. package/lib/models/event/app-event-type.enum.d.ts +4 -1
  114. package/lib/models/export/export-data-table.d.ts +9 -0
  115. package/lib/models/logbook/logbook-period.d.ts +4 -0
  116. package/lib/models/logbook/vehicle-claim.d.ts +20 -3
  117. package/lib/models/logbook/vehicle-logbook.d.ts +8 -2
  118. package/lib/models/logbook/vehicle.d.ts +5 -7
  119. package/lib/models/pdf/pdf-orientation.enum.d.ts +4 -0
  120. package/lib/models/transaction/transaction.d.ts +2 -2
  121. package/lib/services/account-setup/account-setup.service.d.ts +43 -0
  122. package/lib/services/http/bank/bank-account/bank-account.service.d.ts +2 -7
  123. package/lib/services/http/bank/bank-connection/bank-connection.service.d.ts +2 -7
  124. package/lib/services/http/bank/bank-transaction/bank-transaction.service.d.ts +3 -8
  125. package/lib/services/http/bank/basiq/basiq.service.d.ts +2 -7
  126. package/lib/services/http/chat/chat.service.d.ts +4 -7
  127. package/lib/services/http/chat/message/message.service.d.ts +4 -7
  128. package/lib/services/http/chat/message-document/message-document.service.d.ts +3 -3
  129. package/lib/services/http/depreciation/depreciation.service.d.ts +2 -11
  130. package/lib/services/http/document/document-folder/document-folder.service.d.ts +0 -6
  131. package/lib/services/http/firm/client-income/client-income-types.service.d.ts +18 -0
  132. package/lib/services/http/firm/client-movement/client-movement.service.d.ts +2 -7
  133. package/lib/services/http/income-source/income-source-forecast/income-source-forecast.service.d.ts +2 -7
  134. package/lib/services/http/income-source/income-source.service.d.ts +0 -6
  135. package/lib/services/http/income-source/salary-forecast/salary-forecast.service.d.ts +1 -7
  136. package/lib/services/http/income-source/sole-forecast/sole-forecast.service.d.ts +2 -7
  137. package/lib/services/http/loan/loan.service.d.ts +2 -7
  138. package/lib/services/http/property/property-document/property-document.service.d.ts +3 -8
  139. package/lib/services/http/property/property-share/property-share.service.d.ts +2 -7
  140. package/lib/services/http/property/property.service.d.ts +2 -7
  141. package/lib/services/http/rest/rest.service.d.ts +17 -2
  142. package/lib/services/http/service-notification/service-notification.service.d.ts +4 -7
  143. package/lib/services/http/subscription/subscription.service.d.ts +0 -1
  144. package/lib/services/http/tax-review/tax-review-history/tax-review-history.service.d.ts +7 -7
  145. package/lib/services/http/tax-review/tax-review.service.d.ts +1 -7
  146. package/lib/services/http/tax-summary/tax-summary.service.d.ts +2 -1
  147. package/lib/services/http/transaction/transaction-allocation/transaction-allocation.service.d.ts +3 -8
  148. package/lib/services/http/transaction/transaction.service.d.ts +4 -12
  149. package/lib/services/http/user/user-event-setting/user-event-setting.service.d.ts +0 -6
  150. package/lib/services/http/user/user-event-type/user-event-type.service.d.ts +0 -6
  151. package/lib/services/http/vehicle/messages.enum.d.ts +11 -0
  152. package/lib/services/http/vehicle/vehicle-claim.service.d.ts +13 -0
  153. package/lib/services/http/vehicle/vehicle-logbook.service.d.ts +22 -0
  154. package/lib/services/http/vehicle/vehicle.service.d.ts +17 -80
  155. package/lib/services/pdf/pdf.service.d.ts +16 -2
  156. package/lib/services/property/property-holding-costs/property-holding-costs.service.d.ts +24 -0
  157. package/lib/validators/at-least-one.validator.d.ts +6 -0
  158. package/lib/validators/index.d.ts +1 -0
  159. package/package.json +1 -1
  160. package/public-api.d.ts +15 -1
  161. package/esm2015/lib/collections/logbook.collection.js +0 -97
  162. package/lib/collections/logbook.collection.d.ts +0 -19
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/has'), require('lodash/get'), require('lodash/flatten'), require('lodash/first'), require('lodash/last'), require('lodash/uniqBy'), require('lodash/concat'), require('lodash/compact'), require('moment'), require('moment-range'), require('lodash/cloneDeep'), require('@angular/forms'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
- typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/has', 'lodash/get', 'lodash/flatten', 'lodash/first', 'lodash/last', 'lodash/uniqBy', 'lodash/concat', 'lodash/compact', 'moment', 'moment-range', 'lodash/cloneDeep', '@angular/forms', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.has, global.get, global.flatten, global.first, global.last, global.uniqBy, global.concat, global.compact, global.moment, global.momentRange, global.cloneDeep$1, global.ng.forms, global._, global.eventsource_min_js, global.ng.router, global.clone, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, common, i1, rxjs, operators, classTransformer, angularJwt, has, get, flatten, first, last, uniqBy, concat, compact, moment, momentRange, cloneDeep$1, forms, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('lodash/last'), require('lodash/uniqBy'), require('lodash/concat'), require('lodash/compact'), require('moment'), require('moment-range'), require('lodash/cloneDeep'), require('@angular/forms'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
+ typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'lodash/last', 'lodash/uniqBy', 'lodash/concat', 'lodash/compact', 'moment', 'moment-range', 'lodash/cloneDeep', '@angular/forms', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.flatten, global.hasIn, global.first, global.last, global.uniqBy, global.concat, global.compact, global.moment, global.momentRange, global.cloneDeep$1, global.ng.forms, global._, global.eventsource_min_js, global.ng.router, global.clone, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
+ })(this, (function (exports, i0, i2, i1, rxjs, operators, classTransformer, angularJwt, get, flatten, hasIn, first, last, uniqBy, concat, compact, moment, momentRange, cloneDeep$1, forms, _, eventsource_min_js, i1$1, clone, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -25,10 +25,11 @@
25
25
  }
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
+ var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
28
29
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
29
- var has__default = /*#__PURE__*/_interopDefaultLegacy(has);
30
30
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
31
31
  var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
32
+ var hasIn__default = /*#__PURE__*/_interopDefaultLegacy(hasIn);
32
33
  var first__default = /*#__PURE__*/_interopDefaultLegacy(first);
33
34
  var last__default = /*#__PURE__*/_interopDefaultLegacy(last);
34
35
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
@@ -1103,10 +1104,10 @@
1103
1104
  return TtCoreModule;
1104
1105
  }());
1105
1106
  TtCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1106
- TtCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [common.CommonModule,
1107
+ TtCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [i2.CommonModule,
1107
1108
  InterceptorsModule] });
1108
1109
  TtCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [[
1109
- common.CommonModule,
1110
+ i2.CommonModule,
1110
1111
  InterceptorsModule
1111
1112
  ]] });
1112
1113
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, decorators: [{
@@ -1114,7 +1115,7 @@
1114
1115
  args: [{
1115
1116
  declarations: [],
1116
1117
  imports: [
1117
- common.CommonModule,
1118
+ i2.CommonModule,
1118
1119
  InterceptorsModule
1119
1120
  ]
1120
1121
  }]
@@ -1140,8 +1141,8 @@
1140
1141
  if (!collection.length) {
1141
1142
  return;
1142
1143
  }
1143
- // Check if the first collection item has property by path
1144
- if (!has__default["default"](collection.items[0], path)) {
1144
+ // Do nothing if provided path was not found in the 1st collection's item
1145
+ if (!hasIn__default["default"](collection.items[0], path.split('.')[0])) {
1145
1146
  return;
1146
1147
  }
1147
1148
  this.groupItems(collection, path);
@@ -1358,9 +1359,26 @@
1358
1359
  enumerable: false,
1359
1360
  configurable: true
1360
1361
  });
1362
+ Collection.prototype.getByDateRange = function (from, to, dateField) {
1363
+ if (dateField === void 0) { dateField = 'date'; }
1364
+ return this.create(this.items.filter(function (item) { return item[dateField] >= from && item[dateField] <= to; }));
1365
+ };
1361
1366
  return Collection;
1362
1367
  }());
1363
1368
 
1369
+ var AccountSetupItemCollection = /** @class */ (function (_super) {
1370
+ __extends(AccountSetupItemCollection, _super);
1371
+ function AccountSetupItemCollection(items) {
1372
+ var _this = _super.call(this, items) || this;
1373
+ _this.sortBy('isCompleted', false);
1374
+ return _this;
1375
+ }
1376
+ AccountSetupItemCollection.prototype.isCompleted = function () {
1377
+ return this.getBy('isCompleted', true).length === this.length;
1378
+ };
1379
+ return AccountSetupItemCollection;
1380
+ }(Collection));
1381
+
1364
1382
  exports.BankAccountTypeEnum = void 0;
1365
1383
  (function (BankAccountTypeEnum) {
1366
1384
  BankAccountTypeEnum[BankAccountTypeEnum["TRANSACTION"] = 1] = "TRANSACTION";
@@ -1624,7 +1642,7 @@
1624
1642
  BankTransactionCollection.prototype.groupByTransaction = function (allocations) {
1625
1643
  var _this = this;
1626
1644
  // Group allocations by transaction id
1627
- var allocationsByTransactions = new CollectionDictionary(allocations, 'transaction');
1645
+ var allocationsByTransactions = new CollectionDictionary(allocations, 'transaction.id');
1628
1646
  // Init an empty dictionary we will fill below
1629
1647
  var bankTransactionsByTransactions = new CollectionDictionary(new BankTransactionCollection([]));
1630
1648
  // Fill dictionary with the same keys as at allocationsByTransactions
@@ -1968,6 +1986,32 @@
1968
1986
  TransactionCollection.prototype.getByAllocations = function (allocations) {
1969
1987
  return new TransactionCollection(this.items.filter(function (transaction) { return allocations.hasTransaction(transaction); }));
1970
1988
  };
1989
+ /**
1990
+ * Get transactions related to Vehicle category
1991
+ */
1992
+ TransactionCollection.prototype.getVehicleTransactions = function () {
1993
+ return this.create(this.items.filter(function (transaction) {
1994
+ return transaction.isVehicleTransaction();
1995
+ }));
1996
+ };
1997
+ /**
1998
+ * Get new transaction collection filtered by tank type
1999
+ */
2000
+ TransactionCollection.prototype.getByTankType = function (tankType) {
2001
+ return this.create(this.items.filter(function (transaction) {
2002
+ switch (tankType) {
2003
+ case exports.TankTypeEnum.PROPERTY:
2004
+ return transaction.isPropertyTank();
2005
+ case exports.TankTypeEnum.WORK:
2006
+ return transaction.isWorkTank();
2007
+ case exports.TankTypeEnum.SOLE:
2008
+ return transaction.isSoleTank();
2009
+ // Transaction may be not related to any tank type (personal)
2010
+ default:
2011
+ return false;
2012
+ }
2013
+ }));
2014
+ };
1971
2015
  return TransactionCollection;
1972
2016
  }(Collection));
1973
2017
 
@@ -2019,15 +2063,6 @@
2019
2063
  enumerable: false,
2020
2064
  configurable: true
2021
2065
  });
2022
- /**
2023
- * Get new depreciations collections filtered by tank type
2024
- */
2025
- DepreciationCollection.prototype.getByTankType = function (tankType) {
2026
- if (tankType === exports.TankTypeEnum.PROPERTY) {
2027
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isPropertyTank(); }));
2028
- }
2029
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isWorkTank(); }));
2030
- };
2031
2066
  DepreciationCollection.prototype.getByPropertiesIds = function (ids) {
2032
2067
  return new DepreciationCollection(this.items.filter(function (depreciation) { var _a; return ids.includes((_a = depreciation.property) === null || _a === void 0 ? void 0 : _a.id); }));
2033
2068
  };
@@ -2063,6 +2098,29 @@
2063
2098
  return depreciation.depreciationCapitalProject;
2064
2099
  })), 'id');
2065
2100
  };
2101
+ /**
2102
+ * Get a new collection of depreciations related to vehicles
2103
+ */
2104
+ DepreciationCollection.prototype.getVehicleDepreciations = function () {
2105
+ return this.create(this.items.filter(function (depreciation) {
2106
+ return depreciation.isVehicleDepreciation();
2107
+ }));
2108
+ };
2109
+ DepreciationCollection.prototype.getByTankType = function (tankType) {
2110
+ return this.create(this.items.filter(function (depreciation) {
2111
+ switch (tankType) {
2112
+ case exports.TankTypeEnum.PROPERTY:
2113
+ return depreciation.isPropertyTank();
2114
+ case exports.TankTypeEnum.WORK:
2115
+ return depreciation.isWorkTank();
2116
+ case exports.TankTypeEnum.SOLE:
2117
+ return depreciation.isSoleTank();
2118
+ // case for other tank or some extra
2119
+ default:
2120
+ return false;
2121
+ }
2122
+ }));
2123
+ };
2066
2124
  /**
2067
2125
  * Create TransactionCollection from depreciation items
2068
2126
  */
@@ -2170,6 +2228,48 @@
2170
2228
  return LoanCollection;
2171
2229
  }(Collection));
2172
2230
 
2231
+ var MessageCollection = /** @class */ (function (_super) {
2232
+ __extends(MessageCollection, _super);
2233
+ function MessageCollection() {
2234
+ return _super !== null && _super.apply(this, arguments) || this;
2235
+ }
2236
+ MessageCollection.prototype.getFirstUnreadMessage = function (user) {
2237
+ return this.items.find(function (message) {
2238
+ return !message.isRead() && message.isFromEmployee() !== user.isEmployee();
2239
+ });
2240
+ };
2241
+ /**
2242
+ * Get List of unread chats
2243
+ */
2244
+ MessageCollection.prototype.getUnread = function () {
2245
+ return this.items.filter(function (message) { return !message.readAt; });
2246
+ };
2247
+ /**
2248
+ * Check if chat has unread chats
2249
+ */
2250
+ MessageCollection.prototype.hasUnread = function () {
2251
+ return !!this.getUnread().length;
2252
+ };
2253
+ return MessageCollection;
2254
+ }(Collection));
2255
+
2256
+ /**
2257
+ * Collection of MessageDocument instances
2258
+ */
2259
+ var MessageDocumentCollection = /** @class */ (function (_super) {
2260
+ __extends(MessageDocumentCollection, _super);
2261
+ function MessageDocumentCollection() {
2262
+ return _super !== null && _super.apply(this, arguments) || this;
2263
+ }
2264
+ /**
2265
+ * get list of documents which are not attached to any message
2266
+ */
2267
+ MessageDocumentCollection.prototype.getUnattached = function () {
2268
+ return new MessageDocumentCollection(this.items.filter(function (doc) { return !doc.message; }));
2269
+ };
2270
+ return MessageDocumentCollection;
2271
+ }(Collection));
2272
+
2173
2273
  var FinancialYear = /** @class */ (function () {
2174
2274
  function FinancialYear(date) {
2175
2275
  this.yearStartDate = '-07-01';
@@ -2219,168 +2319,6 @@
2219
2319
  }());
2220
2320
  FinancialYear.startMonthIndex = 6;
2221
2321
 
2222
- var LogbookPeriod = /** @class */ (function () {
2223
- function LogbookPeriod() {
2224
- }
2225
- return LogbookPeriod;
2226
- }());
2227
- __decorate([
2228
- classTransformer.Type(function () { return Date; })
2229
- ], LogbookPeriod.prototype, "from", void 0);
2230
- __decorate([
2231
- classTransformer.Type(function () { return Date; })
2232
- ], LogbookPeriod.prototype, "to", void 0);
2233
-
2234
- // Class contain array of vehicle logbooks and calculate the best period for logbook claim method
2235
- var LogbookCollection = /** @class */ (function () {
2236
- function LogbookCollection(vehicles) {
2237
- // 12 weeks in milliseconds to check logbooks range
2238
- this.logbookClaimRange = 12 * 7 * 24 * 3600 * 1000;
2239
- this.trips = vehicles.map(function (vehicle) { return vehicle.logbook; }).flat();
2240
- this.financialYear = new FinancialYear();
2241
- this.setInitialBestPeriod();
2242
- }
2243
- Object.defineProperty(LogbookCollection.prototype, "isAutomaticLogbookCalculationAllowed", {
2244
- // check if summary logbooks date range less than 84 days (12 weeks)
2245
- get: function () {
2246
- // forbid automatic logbook calculation if no logbook trips exist
2247
- if (!this.trips.length) {
2248
- return false;
2249
- }
2250
- // forbid automatic logbook calculation if logbook trips summary date range less than 12 weeks
2251
- return this.trips.slice(-1)[0].date.getTime() - this.trips[0].date.getTime() >= this.logbookClaimRange;
2252
- },
2253
- enumerable: false,
2254
- configurable: true
2255
- });
2256
- Object.defineProperty(LogbookCollection.prototype, "bestPeriod", {
2257
- get: function () {
2258
- // don't calculate if not allowed
2259
- if (!this.isAutomaticLogbookCalculationAllowed) {
2260
- return null;
2261
- }
2262
- this.calculateBestPeriod();
2263
- return this._bestPeriod;
2264
- },
2265
- enumerable: false,
2266
- configurable: true
2267
- });
2268
- Object.defineProperty(LogbookCollection.prototype, "workTrips", {
2269
- get: function () {
2270
- return this.trips.filter(function (logbook) { return logbook.isWork; });
2271
- },
2272
- enumerable: false,
2273
- configurable: true
2274
- });
2275
- // calculate best period for logbook claim method
2276
- LogbookCollection.prototype.calculateBestPeriod = function () {
2277
- var _this = this;
2278
- // set default best period values for real values comparison
2279
- this.setInitialBestPeriod();
2280
- // get best period with each trip date as start date
2281
- this.workTrips.forEach(function (logbook) {
2282
- var dateRange = _this.getDateRange(logbook.date);
2283
- // get all trips included in current 12 weeks period
2284
- var tripsInRange = _this.trips.filter(function (l) {
2285
- return l.date >= dateRange.from && l.date <= dateRange.to;
2286
- });
2287
- // get work trips included in current 12 weeks period
2288
- var workTripsInRange = tripsInRange.filter(function (l) { return l.isWork; });
2289
- // calculate sum of work kilometers in current 12 weeks range
2290
- var currentRangeKilometers = _this.getKilometersAmount(workTripsInRange);
2291
- // overwrite best period with current 12 weeks range if amount of kilometers is bigger
2292
- if (currentRangeKilometers > _this._bestPeriod.kilometers) {
2293
- _this._bestPeriod = {
2294
- from: dateRange.from,
2295
- to: dateRange.to,
2296
- kilometers: currentRangeKilometers,
2297
- workUsage: _this.getLogbooksWorkUsage(tripsInRange, workTripsInRange)
2298
- };
2299
- }
2300
- });
2301
- };
2302
- LogbookCollection.prototype.getDateRange = function (from) {
2303
- // set end date after 12 weeks after start date
2304
- var to = new Date(from.getTime() + this.logbookClaimRange);
2305
- // set as period last 12 weeks of current year if period end date after end of current year
2306
- if (to > this.financialYear.endDate) {
2307
- to = this.financialYear.endDate;
2308
- from = new Date(to.getTime() - this.logbookClaimRange);
2309
- }
2310
- return { from: from, to: to };
2311
- };
2312
- // calculate kilometers amount for passed trips
2313
- LogbookCollection.prototype.getKilometersAmount = function (logbooks) {
2314
- if (!logbooks.length) {
2315
- return 0;
2316
- }
2317
- return logbooks.map(function (logbook) { return logbook.odometerEnd - logbook.odometerStart; })
2318
- .reduce(function (prev, next) { return prev + Number(next); });
2319
- };
2320
- // calculate work usage for passed trips
2321
- LogbookCollection.prototype.getLogbooksWorkUsage = function (logbooks, workLogbooks) {
2322
- var kilometers = this.getKilometersAmount(logbooks);
2323
- var workKilometers = this.getKilometersAmount(workLogbooks);
2324
- return Math.round(workKilometers / kilometers * 100);
2325
- };
2326
- // set default best period with zero values and fin year start date for comparison in calculation
2327
- LogbookCollection.prototype.setInitialBestPeriod = function () {
2328
- // set 1st of July of current year as default start date for best period
2329
- var startDate = this.financialYear.startDate;
2330
- // set end custom-date after 12 weeks from start date
2331
- var endDate = new Date(startDate.getTime() + this.logbookClaimRange);
2332
- this._bestPeriod = classTransformer.plainToClass(LogbookPeriod, {
2333
- from: startDate,
2334
- to: endDate,
2335
- kilometers: 0,
2336
- workUsage: 0
2337
- });
2338
- };
2339
- return LogbookCollection;
2340
- }());
2341
-
2342
- var MessageCollection = /** @class */ (function (_super) {
2343
- __extends(MessageCollection, _super);
2344
- function MessageCollection() {
2345
- return _super !== null && _super.apply(this, arguments) || this;
2346
- }
2347
- MessageCollection.prototype.getFirstUnreadMessage = function (user) {
2348
- return this.items.find(function (message) {
2349
- return !message.isRead() && message.isFromEmployee() !== user.isEmployee();
2350
- });
2351
- };
2352
- /**
2353
- * Get List of unread chats
2354
- */
2355
- MessageCollection.prototype.getUnread = function () {
2356
- return this.items.filter(function (message) { return !message.readAt; });
2357
- };
2358
- /**
2359
- * Check if chat has unread chats
2360
- */
2361
- MessageCollection.prototype.hasUnread = function () {
2362
- return !!this.getUnread().length;
2363
- };
2364
- return MessageCollection;
2365
- }(Collection));
2366
-
2367
- /**
2368
- * Collection of MessageDocument instances
2369
- */
2370
- var MessageDocumentCollection = /** @class */ (function (_super) {
2371
- __extends(MessageDocumentCollection, _super);
2372
- function MessageDocumentCollection() {
2373
- return _super !== null && _super.apply(this, arguments) || this;
2374
- }
2375
- /**
2376
- * get list of documents which are not attached to any message
2377
- */
2378
- MessageDocumentCollection.prototype.getUnattached = function () {
2379
- return new MessageDocumentCollection(this.items.filter(function (doc) { return !doc.message; }));
2380
- };
2381
- return MessageDocumentCollection;
2382
- }(Collection));
2383
-
2384
2322
  var PropertyCollection = /** @class */ (function (_super) {
2385
2323
  __extends(PropertyCollection, _super);
2386
2324
  function PropertyCollection() {
@@ -2673,6 +2611,8 @@
2673
2611
  (function (ChartAccountsHeadingVehicleListEnum) {
2674
2612
  ChartAccountsHeadingVehicleListEnum[ChartAccountsHeadingVehicleListEnum["WORK_RELATED_CAR_EXPENSES"] = 8] = "WORK_RELATED_CAR_EXPENSES";
2675
2613
  ChartAccountsHeadingVehicleListEnum[ChartAccountsHeadingVehicleListEnum["DEPRECIATION_VEHICLES"] = 9] = "DEPRECIATION_VEHICLES";
2614
+ ChartAccountsHeadingVehicleListEnum[ChartAccountsHeadingVehicleListEnum["KLMS"] = 60] = "KLMS";
2615
+ ChartAccountsHeadingVehicleListEnum[ChartAccountsHeadingVehicleListEnum["FUEL_OIL"] = 61] = "FUEL_OIL";
2676
2616
  })(exports.ChartAccountsHeadingVehicleListEnum || (exports.ChartAccountsHeadingVehicleListEnum = {}));
2677
2617
 
2678
2618
  exports.ChartAccountsListEnum = void 0;
@@ -2684,16 +2624,17 @@
2684
2624
  ChartAccountsListEnum[ChartAccountsListEnum["BUILDING_AT_COST"] = 304] = "BUILDING_AT_COST";
2685
2625
  ChartAccountsListEnum[ChartAccountsListEnum["MANAGEMENT_FEES_PLATFORM_FEES"] = 656] = "MANAGEMENT_FEES_PLATFORM_FEES";
2686
2626
  ChartAccountsListEnum[ChartAccountsListEnum["KLMS_TRAVELLED_FOR_WORK"] = 24] = "KLMS_TRAVELLED_FOR_WORK";
2627
+ ChartAccountsListEnum[ChartAccountsListEnum["KLMS_TRAVELLED"] = 683] = "KLMS_TRAVELLED";
2687
2628
  ChartAccountsListEnum[ChartAccountsListEnum["DIRECTOR_FEES"] = 6] = "DIRECTOR_FEES";
2688
2629
  ChartAccountsListEnum[ChartAccountsListEnum["SALARY_OR_WAGES"] = 2] = "SALARY_OR_WAGES";
2689
2630
  ChartAccountsListEnum[ChartAccountsListEnum["VEHICLES"] = 25] = "VEHICLES";
2690
2631
  ChartAccountsListEnum[ChartAccountsListEnum["COMMERCIAL_VEHICLES"] = 26] = "COMMERCIAL_VEHICLES";
2632
+ ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_INTEREST"] = 37] = "VEHICLE_LOAN_INTEREST";
2633
+ ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_PRINCIPAL"] = 38] = "VEHICLE_LOAN_PRINCIPAL";
2691
2634
  ChartAccountsListEnum[ChartAccountsListEnum["TAX_INSTALMENTS"] = 662] = "TAX_INSTALMENTS";
2692
2635
  ChartAccountsListEnum[ChartAccountsListEnum["INTEREST_EARNED"] = 22] = "INTEREST_EARNED";
2693
2636
  ChartAccountsListEnum[ChartAccountsListEnum["TRUST_INCOME"] = 567] = "TRUST_INCOME";
2694
2637
  ChartAccountsListEnum[ChartAccountsListEnum["TAX_OFFSETS_N_R_A_S"] = 571] = "TAX_OFFSETS_N_R_A_S";
2695
- ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_INTEREST"] = 37] = "VEHICLE_LOAN_INTEREST";
2696
- ChartAccountsListEnum[ChartAccountsListEnum["VEHICLE_LOAN_PRINCIPAL"] = 38] = "VEHICLE_LOAN_PRINCIPAL";
2697
2638
  })(exports.ChartAccountsListEnum || (exports.ChartAccountsListEnum = {}));
2698
2639
 
2699
2640
  var DepreciationCapitalProject$1 = /** @class */ (function () {
@@ -2855,6 +2796,25 @@
2855
2796
  ChartAccounts.prototype.isKlmsForWork = function () {
2856
2797
  return this.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK;
2857
2798
  };
2799
+ /**
2800
+ * Check if chart accounts id is related for 'Klms travelled for sole' category
2801
+ */
2802
+ ChartAccounts.prototype.isKlmsForSole = function () {
2803
+ return this.id === exports.ChartAccountsListEnum.KLMS_TRAVELLED;
2804
+ };
2805
+ /**
2806
+ * Check if accounts id is related for KLMs category related to passed tank type
2807
+ */
2808
+ ChartAccounts.prototype.isKLMsByTankType = function (tankType) {
2809
+ switch (tankType) {
2810
+ case exports.TankTypeEnum.WORK:
2811
+ return this.isKlmsForWork();
2812
+ case exports.TankTypeEnum.SOLE:
2813
+ return this.isKlmsForSole();
2814
+ default:
2815
+ return false;
2816
+ }
2817
+ };
2858
2818
  /**
2859
2819
  * Check if chart accounts id is related for 'NRAS Tax Offset' category
2860
2820
  */
@@ -2949,6 +2909,18 @@
2949
2909
  ChartAccounts.prototype.isVehicleLoanExpense = function () {
2950
2910
  return this.id === exports.ChartAccountsListEnum.VEHICLE_LOAN_INTEREST || this.id === exports.ChartAccountsListEnum.VEHICLE_LOAN_PRINCIPAL;
2951
2911
  };
2912
+ /**
2913
+ * Get chart accounts value for current financial year
2914
+ */
2915
+ ChartAccounts.prototype.getCurrentYearValue = function () {
2916
+ return this.getValueByYear(new FinancialYear().year);
2917
+ };
2918
+ /**
2919
+ * Get chart accounts value by financial year
2920
+ */
2921
+ ChartAccounts.prototype.getValueByYear = function (year) {
2922
+ return this.values.find(function (value) { return value.financialYear === year; });
2923
+ };
2952
2924
  return ChartAccounts;
2953
2925
  }(ChartAccounts$1));
2954
2926
  __decorate([
@@ -3013,7 +2985,6 @@
3013
2985
  UserStatusEnum[UserStatusEnum["INACTIVE"] = 0] = "INACTIVE";
3014
2986
  UserStatusEnum[UserStatusEnum["ON_BOARDING"] = 1] = "ON_BOARDING";
3015
2987
  UserStatusEnum[UserStatusEnum["ACTIVE"] = 2] = "ACTIVE";
3016
- UserStatusEnum[UserStatusEnum["TRIAL"] = 3] = "TRIAL";
3017
2988
  })(exports.UserStatusEnum || (exports.UserStatusEnum = {}));
3018
2989
 
3019
2990
  exports.UserRolesEnum = void 0;
@@ -3103,12 +3074,12 @@
3103
3074
  classTransformer.Type((function () { return Country; }))
3104
3075
  ], Address.prototype, "country", void 0);
3105
3076
 
3106
- var _a$3;
3107
- var USER_WORK_POSITION = (_a$3 = {},
3108
- _a$3[exports.UserRolesEnum.EMPLOYEE] = 'Employee',
3109
- _a$3[exports.UserRolesEnum.FIRM_MANAGER] = 'Manager',
3110
- _a$3[exports.UserRolesEnum.FIRM_OWNER] = 'Firm Owner',
3111
- _a$3);
3077
+ var _a$4;
3078
+ var USER_WORK_POSITION = (_a$4 = {},
3079
+ _a$4[exports.UserRolesEnum.EMPLOYEE] = 'Employee',
3080
+ _a$4[exports.UserRolesEnum.FIRM_MANAGER] = 'Manager',
3081
+ _a$4[exports.UserRolesEnum.FIRM_OWNER] = 'Firm Owner',
3082
+ _a$4);
3112
3083
 
3113
3084
  var ClientDetails$1 = /** @class */ (function () {
3114
3085
  function ClientDetails() {
@@ -3276,22 +3247,22 @@
3276
3247
  SubscriptionTypeEnum[SubscriptionTypeEnum["INVESTOR_PLUS"] = 3] = "INVESTOR_PLUS";
3277
3248
  })(exports.SubscriptionTypeEnum || (exports.SubscriptionTypeEnum = {}));
3278
3249
 
3250
+ var _a$3;
3251
+ var SUBSCRIPTION_TITLE = (_a$3 = {},
3252
+ _a$3[exports.SubscriptionTypeEnum.WITHOUT_SUBSCRIPTION] = 'Without subscription',
3253
+ _a$3[exports.SubscriptionTypeEnum.INDIVIDUAL] = 'Individual',
3254
+ _a$3[exports.SubscriptionTypeEnum.INVESTOR] = 'Investor',
3255
+ _a$3[exports.SubscriptionTypeEnum.INVESTOR_PLUS] = 'Investor plus',
3256
+ _a$3);
3257
+
3279
3258
  var _a$2;
3280
- var SUBSCRIPTION_TITLE = (_a$2 = {},
3259
+ var SUBSCRIPTION_DESCRIPTION = (_a$2 = {},
3281
3260
  _a$2[exports.SubscriptionTypeEnum.WITHOUT_SUBSCRIPTION] = 'Without subscription',
3282
- _a$2[exports.SubscriptionTypeEnum.INDIVIDUAL] = 'Individual',
3283
- _a$2[exports.SubscriptionTypeEnum.INVESTOR] = 'Investor',
3284
- _a$2[exports.SubscriptionTypeEnum.INVESTOR_PLUS] = 'Investor plus',
3261
+ _a$2[exports.SubscriptionTypeEnum.INDIVIDUAL] = 'Manage income and expenses via live bank feeds. Keep receipts safe, maximise deductions & minimise tax.',
3262
+ _a$2[exports.SubscriptionTypeEnum.INVESTOR] = 'Property made easy with smart tax tools and real-time information to help control how much tax you pay.',
3263
+ _a$2[exports.SubscriptionTypeEnum.INVESTOR_PLUS] = 'Add your whole portfolio, including investment properties, home and properties in trusts. For 3+ properties an extra $6 will be charged per property.',
3285
3264
  _a$2);
3286
3265
 
3287
- var _a$1;
3288
- var SUBSCRIPTION_DESCRIPTION = (_a$1 = {},
3289
- _a$1[exports.SubscriptionTypeEnum.WITHOUT_SUBSCRIPTION] = 'Without subscription',
3290
- _a$1[exports.SubscriptionTypeEnum.INDIVIDUAL] = 'Manage income and expenses via live bank feeds. Keep receipts safe, maximise deductions & minimise tax.',
3291
- _a$1[exports.SubscriptionTypeEnum.INVESTOR] = 'Property made easy with smart tax tools and real-time information to help control how much tax you pay.',
3292
- _a$1[exports.SubscriptionTypeEnum.INVESTOR_PLUS] = 'Add your whole portfolio, including investment properties, home and properties in trusts. For 3+ properties an extra $6 will be charged per property.',
3293
- _a$1);
3294
-
3295
3266
  var PROPERTY_INVESTOR_MAX_PROPERTIES = 2;
3296
3267
  var ServiceSubscription = /** @class */ (function (_super) {
3297
3268
  __extends(ServiceSubscription, _super);
@@ -3844,10 +3815,11 @@
3844
3815
  TaxExemptionEnum[TaxExemptionEnum["OTHER"] = 7] = "OTHER";
3845
3816
  })(exports.TaxExemptionEnum || (exports.TaxExemptionEnum = {}));
3846
3817
 
3847
- var PropertyCategoryListEnum;
3818
+ exports.PropertyCategoryListEnum = void 0;
3848
3819
  (function (PropertyCategoryListEnum) {
3849
3820
  PropertyCategoryListEnum[PropertyCategoryListEnum["OWNER_OCCUPIED"] = 3] = "OWNER_OCCUPIED";
3850
- })(PropertyCategoryListEnum || (PropertyCategoryListEnum = {}));
3821
+ PropertyCategoryListEnum[PropertyCategoryListEnum["VACANT_LAND"] = 5] = "VACANT_LAND";
3822
+ })(exports.PropertyCategoryListEnum || (exports.PropertyCategoryListEnum = {}));
3851
3823
 
3852
3824
  exports.TaxExemptionMetadataEnum = void 0;
3853
3825
  (function (TaxExemptionMetadataEnum) {
@@ -4072,7 +4044,7 @@
4072
4044
  }
4073
4045
  switch (true) {
4074
4046
  // exemption for main residence properties
4075
- case this.category.id === PropertyCategoryListEnum.OWNER_OCCUPIED:
4047
+ case this.category.id === exports.PropertyCategoryListEnum.OWNER_OCCUPIED:
4076
4048
  return exports.TaxExemptionEnum.PPR;
4077
4049
  // exemption for investment properties owned for at least one year
4078
4050
  case this.isOneYearExemptionApplicable(sale):
@@ -4874,6 +4846,10 @@
4874
4846
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
4875
4847
  _this.forecasts = [];
4876
4848
  _this.type = exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
4849
+ /**
4850
+ * @TODO remove after ? signs removed from db models
4851
+ */
4852
+ _this.amount = 0;
4877
4853
  return _this;
4878
4854
  }
4879
4855
  Depreciation.prototype.isCapital = function () {
@@ -5643,7 +5619,7 @@
5643
5619
  TransactionAllocationCollection.prototype.groupByBankAccount = function (bankTransactions) {
5644
5620
  var _this = this;
5645
5621
  // Group bank transactions by bank account id
5646
- var bankTransactionsByBankAccount = new CollectionDictionary(bankTransactions, 'bankAccount');
5622
+ var bankTransactionsByBankAccount = new CollectionDictionary(bankTransactions, 'bankAccount.id');
5647
5623
  // Create empty dictionary of transaction allocations
5648
5624
  var allocationsByBankAccount = new CollectionDictionary(new TransactionAllocationCollection([]));
5649
5625
  // Fill allocations dictionary with bank transactions dictionary keys and allocations related with each bank transaction collection
@@ -5681,6 +5657,124 @@
5681
5657
  return UserEventSettingCollection;
5682
5658
  }(Collection));
5683
5659
 
5660
+ /**
5661
+ * Class contains traveled kilometers and work usage percent in 12 weeks date range
5662
+ */
5663
+ var LogbookPeriod = /** @class */ (function () {
5664
+ function LogbookPeriod() {
5665
+ }
5666
+ LogbookPeriod.prototype.isEndOfYear = function () {
5667
+ return this.to === new FinancialYear().endDate;
5668
+ };
5669
+ return LogbookPeriod;
5670
+ }());
5671
+ __decorate([
5672
+ classTransformer.Type(function () { return Date; })
5673
+ ], LogbookPeriod.prototype, "from", void 0);
5674
+ __decorate([
5675
+ classTransformer.Type(function () { return Date; })
5676
+ ], LogbookPeriod.prototype, "to", void 0);
5677
+
5678
+ /**
5679
+ * 12 weeks in milliseconds
5680
+ * "To work out your business-use percentage, you need to keep a logbook and the odometer readings for the logbook period.
5681
+ * The logbook period is a minimum continuous period of 12 weeks." © Nicole Kelly
5682
+ */
5683
+ var LOGBOOK_PERIOD_DURATION = 12 * 7 * 24 * 3600 * 1000;
5684
+ var VehicleLogbookCollection = /** @class */ (function (_super) {
5685
+ __extends(VehicleLogbookCollection, _super);
5686
+ function VehicleLogbookCollection() {
5687
+ return _super !== null && _super.apply(this, arguments) || this;
5688
+ }
5689
+ /**
5690
+ * Check if we can calculate the best period
5691
+ */
5692
+ VehicleLogbookCollection.prototype.isBestPeriodExist = function () {
5693
+ if (this.items.length < 2) {
5694
+ return false;
5695
+ }
5696
+ return LOGBOOK_PERIOD_DURATION < (this.last.date.getTime() - this.first.date.getTime());
5697
+ };
5698
+ /**
5699
+ * Get collection of non-personal logbooks (work-related, sole-related).
5700
+ */
5701
+ VehicleLogbookCollection.prototype.getBusinessLogbooks = function () {
5702
+ return this.create(this.items.filter(function (logbook) { return logbook.isBusiness(); }));
5703
+ };
5704
+ /**
5705
+ * Logbook Period is the best when it has the biggest amount of work kilometers
5706
+ * Best period duration is defined as LOGBOOK_PERIOD_DURATION (12 weeks) by the ATO
5707
+ */
5708
+ VehicleLogbookCollection.prototype.getBestPeriod = function () {
5709
+ if (!this.isBestPeriodExist()) {
5710
+ return null;
5711
+ }
5712
+ var bestPeriod;
5713
+ var businessLogbooks = this.getBusinessLogbooks().toArray();
5714
+ for (var i = 0; i < businessLogbooks.length; i++) {
5715
+ var logbook = businessLogbooks[i];
5716
+ // no sense to check next logbooks because we already get the end of the year
5717
+ if (bestPeriod && bestPeriod.isEndOfYear()) {
5718
+ break;
5719
+ }
5720
+ var dateRange = this.getPeriodRange(logbook.date);
5721
+ // get logbooks included in current logbook period
5722
+ var logbooksInRange = this.getByDateRange(logbook.date, new Date(logbook.date.getTime() + LOGBOOK_PERIOD_DURATION));
5723
+ var workUsage = logbooksInRange.getWorkUsage();
5724
+ // compare with previous best period and overwrite if needs
5725
+ if (!bestPeriod || workUsage > bestPeriod.workUsage) {
5726
+ bestPeriod = classTransformer.plainToClass(LogbookPeriod, {
5727
+ from: dateRange.from,
5728
+ to: dateRange.to,
5729
+ kilometers: logbooksInRange.getBusinessLogbooks().getKlms(),
5730
+ workUsage: workUsage
5731
+ });
5732
+ }
5733
+ }
5734
+ return bestPeriod;
5735
+ };
5736
+ /**
5737
+ * Calculate total kilometers traveled
5738
+ */
5739
+ VehicleLogbookCollection.prototype.getKlms = function () {
5740
+ return this.items.reduce(function (sum, logbook) { return sum + logbook.getKlms(); }, 0);
5741
+ };
5742
+ /**
5743
+ * Calculate work usage (percent of business-related kilometers from total kilometers)
5744
+ */
5745
+ VehicleLogbookCollection.prototype.getWorkUsage = function () {
5746
+ var totalKilometers = this.getKlms();
5747
+ var workKilometers = this.getBusinessLogbooks().getKlms();
5748
+ return Math.round(workKilometers / totalKilometers * 100);
5749
+ };
5750
+ /**
5751
+ * Get LOGBOOK_PERIOD_DURATION date range from passed start date
5752
+ */
5753
+ VehicleLogbookCollection.prototype.getPeriodRange = function (from) {
5754
+ // set end date after LOGBOOK_PERIOD_DURATION after start date
5755
+ var to = new Date(from.getTime() + LOGBOOK_PERIOD_DURATION);
5756
+ var financialYear = new FinancialYear();
5757
+ // set as period last LOGBOOK_PERIOD_DURATION of current year if period end date after end of current year
5758
+ if (to > financialYear.endDate) {
5759
+ to = financialYear.endDate;
5760
+ from = new Date(to.getTime() - LOGBOOK_PERIOD_DURATION);
5761
+ }
5762
+ return { from: from, to: to };
5763
+ };
5764
+ return VehicleLogbookCollection;
5765
+ }(Collection));
5766
+
5767
+ var VehicleCollection = /** @class */ (function (_super) {
5768
+ __extends(VehicleCollection, _super);
5769
+ function VehicleCollection() {
5770
+ return _super !== null && _super.apply(this, arguments) || this;
5771
+ }
5772
+ VehicleCollection.prototype.getLogbooks = function () {
5773
+ return new VehicleLogbookCollection(flatten__default["default"](this.items.map(function (vehicle) { return vehicle.logbook; })));
5774
+ };
5775
+ return VehicleCollection;
5776
+ }(Collection));
5777
+
5684
5778
  exports.BankAccountStatusEnum = void 0;
5685
5779
  (function (BankAccountStatusEnum) {
5686
5780
  BankAccountStatusEnum[BankAccountStatusEnum["INACTIVE"] = 0] = "INACTIVE";
@@ -6117,6 +6211,15 @@
6117
6211
  VehicleLogbookPurposeEnum[VehicleLogbookPurposeEnum["PERSONAL"] = 2] = "PERSONAL";
6118
6212
  })(exports.VehicleLogbookPurposeEnum || (exports.VehicleLogbookPurposeEnum = {}));
6119
6213
 
6214
+ /**
6215
+ * Account setup item instance is using for account setup checklist
6216
+ */
6217
+ var AccountSetupItem = /** @class */ (function () {
6218
+ function AccountSetupItem() {
6219
+ }
6220
+ return AccountSetupItem;
6221
+ }());
6222
+
6120
6223
  var Bank$1 = /** @class */ (function () {
6121
6224
  function Bank() {
6122
6225
  }
@@ -6648,10 +6751,24 @@
6648
6751
  ChartAccountsTaxLabelsEnum["TAX_DEDUCTED"] = "Tax Deducted";
6649
6752
  })(exports.ChartAccountsTaxLabelsEnum || (exports.ChartAccountsTaxLabelsEnum = {}));
6650
6753
 
6651
- var Chat$1 = /** @class */ (function () {
6652
- function Chat() {
6754
+ var ChartAccountsValue$1 = /** @class */ (function () {
6755
+ function ChartAccountsValue() {
6653
6756
  }
6654
- return Chat;
6757
+ return ChartAccountsValue;
6758
+ }());
6759
+
6760
+ var ChartAccountsValue = /** @class */ (function (_super) {
6761
+ __extends(ChartAccountsValue, _super);
6762
+ function ChartAccountsValue() {
6763
+ return _super !== null && _super.apply(this, arguments) || this;
6764
+ }
6765
+ return ChartAccountsValue;
6766
+ }(ChartAccountsValue$1));
6767
+
6768
+ var Chat$1 = /** @class */ (function () {
6769
+ function Chat() {
6770
+ }
6771
+ return Chat;
6655
6772
  }());
6656
6773
 
6657
6774
  var Chat = /** @class */ (function (_super) {
@@ -6751,6 +6868,30 @@
6751
6868
  classTransformer.Expose()
6752
6869
  ], Message.prototype, "documents", void 0);
6753
6870
 
6871
+ var ClientIncomeTypes$1 = /** @class */ (function () {
6872
+ function ClientIncomeTypes() {
6873
+ }
6874
+ return ClientIncomeTypes;
6875
+ }());
6876
+
6877
+ var ClientIncomeTypes = /** @class */ (function (_super) {
6878
+ __extends(ClientIncomeTypes, _super);
6879
+ function ClientIncomeTypes() {
6880
+ return _super !== null && _super.apply(this, arguments) || this;
6881
+ }
6882
+ Object.defineProperty(ClientIncomeTypes.prototype, "length", {
6883
+ /**
6884
+ * Get count of selected income types
6885
+ */
6886
+ get: function () {
6887
+ return Object.values(this).filter(function (value) { return typeof value === 'boolean' && value; }).length;
6888
+ },
6889
+ enumerable: false,
6890
+ configurable: true
6891
+ });
6892
+ return ClientIncomeTypes;
6893
+ }(ClientIncomeTypes$1));
6894
+
6754
6895
  var ClientInvite$1 = /** @class */ (function () {
6755
6896
  function ClientInvite() {
6756
6897
  }
@@ -7017,34 +7158,34 @@
7017
7158
  return DepreciationGroupItem;
7018
7159
  }(DepreciationGroup));
7019
7160
 
7020
- var _a;
7021
- var DEPRECIATION_GROUPS = (_a = {},
7022
- _a[exports.DepreciationGroupEnum.BORROWING_EXPENSES] = {
7161
+ var _a$1;
7162
+ var DEPRECIATION_GROUPS = (_a$1 = {},
7163
+ _a$1[exports.DepreciationGroupEnum.BORROWING_EXPENSES] = {
7023
7164
  label: 'Borrowing Expenses',
7024
7165
  description: 'Borrowing expenses on loans are deductible over 1826 days (5 years) starting from the date of a loan',
7025
7166
  icon: 'loan'
7026
7167
  },
7027
- _a[exports.DepreciationGroupEnum.BUILDING_IMPROVEMENTS] = {
7168
+ _a$1[exports.DepreciationGroupEnum.BUILDING_IMPROVEMENTS] = {
7028
7169
  label: 'Building & Improvements',
7029
7170
  description: 'Construction costs, renovations and capital improvements which depreciate at 2.5%',
7030
7171
  icon: 'building-improvements'
7031
7172
  },
7032
- _a[exports.DepreciationGroupEnum.PLANT_EQUIPMENT] = {
7173
+ _a$1[exports.DepreciationGroupEnum.PLANT_EQUIPMENT] = {
7033
7174
  label: 'Plant & Equipment',
7034
7175
  description: 'Assets which decline in value over their useful life (as prescribed by the ATO)',
7035
7176
  icon: 'plant-equipment'
7036
7177
  },
7037
- _a[exports.DepreciationGroupEnum.LOW_VALUE_POOL] = {
7178
+ _a$1[exports.DepreciationGroupEnum.LOW_VALUE_POOL] = {
7038
7179
  label: 'Low Value Pool',
7039
7180
  description: 'Items under $1,000 are added to the pool to maximise depreciation',
7040
7181
  icon: 'lvp'
7041
7182
  },
7042
- _a[exports.DepreciationGroupEnum.WRITTEN_OFF_ITEMS] = {
7183
+ _a$1[exports.DepreciationGroupEnum.WRITTEN_OFF_ITEMS] = {
7043
7184
  label: 'Written Off Items',
7044
7185
  description: 'Items below $300, replaced or obsolete are fully deductible',
7045
7186
  icon: 'cart'
7046
7187
  },
7047
- _a);
7188
+ _a$1);
7048
7189
 
7049
7190
  var DepreciationReceipt$1 = /** @class */ (function () {
7050
7191
  function DepreciationReceipt() {
@@ -7212,8 +7353,20 @@
7212
7353
  AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 35] = "USER_UPDATED";
7213
7354
  AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 36] = "VEHICLE_CLAIM_UPDATED";
7214
7355
  AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 37] = "VEHICLE_CLAIM_CREATED";
7356
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 38] = "VEHICLE_LOGBOOK_CREATED";
7357
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 39] = "VEHICLE_LOGBOOK_UPDATED";
7358
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 40] = "VEHICLE_LOGBOOK_DELETED";
7215
7359
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
7216
7360
 
7361
+ /**
7362
+ * Data table structure suitable for export
7363
+ */
7364
+ var ExportDataTable = /** @class */ (function () {
7365
+ function ExportDataTable() {
7366
+ }
7367
+ return ExportDataTable;
7368
+ }());
7369
+
7217
7370
  exports.ExportFormatEnum = void 0;
7218
7371
  (function (ExportFormatEnum) {
7219
7372
  ExportFormatEnum["PDF"] = "PDF";
@@ -7329,20 +7482,18 @@
7329
7482
  function VehicleLogbook() {
7330
7483
  return _super !== null && _super.apply(this, arguments) || this;
7331
7484
  }
7332
- Object.defineProperty(VehicleLogbook.prototype, "kilometres", {
7333
- get: function () {
7334
- return this.odometerEnd - this.odometerStart;
7335
- },
7336
- enumerable: false,
7337
- configurable: true
7338
- });
7339
- Object.defineProperty(VehicleLogbook.prototype, "isWork", {
7340
- get: function () {
7341
- return this.purpose === exports.VehicleLogbookPurposeEnum.BUSINESS;
7342
- },
7343
- enumerable: false,
7344
- configurable: true
7345
- });
7485
+ /**
7486
+ * Get amount of kilometers in this logbook
7487
+ */
7488
+ VehicleLogbook.prototype.getKlms = function () {
7489
+ return this.odometerEnd - this.odometerStart;
7490
+ };
7491
+ /**
7492
+ * Check if logbook is business-related
7493
+ */
7494
+ VehicleLogbook.prototype.isBusiness = function () {
7495
+ return this.purpose === exports.VehicleLogbookPurposeEnum.BUSINESS;
7496
+ };
7346
7497
  return VehicleLogbook;
7347
7498
  }(VehicleLogbook$1));
7348
7499
  __decorate([
@@ -7354,54 +7505,12 @@
7354
7505
  function Vehicle() {
7355
7506
  return _super !== null && _super.apply(this, arguments) || this;
7356
7507
  }
7357
- Object.defineProperty(Vehicle.prototype, "workKilometersPercentage", {
7358
- get: function () {
7359
- return this.workKilometres / this.totalKilometres * 100;
7360
- },
7361
- enumerable: false,
7362
- configurable: true
7363
- });
7364
- Object.defineProperty(Vehicle.prototype, "totalKilometres", {
7365
- get: function () {
7366
- var kilometers = 0;
7367
- this.logbook.forEach(function (lb) {
7368
- kilometers += lb.kilometres;
7369
- });
7370
- return kilometers;
7371
- },
7372
- enumerable: false,
7373
- configurable: true
7374
- });
7375
- Object.defineProperty(Vehicle.prototype, "workKilometres", {
7376
- get: function () {
7377
- var kilometers = 0;
7378
- this.logbook.forEach(function (lb) {
7379
- if (lb.purpose === exports.VehicleLogbookPurposeEnum.BUSINESS) {
7380
- kilometers += lb.kilometres;
7381
- }
7382
- });
7383
- return kilometers;
7384
- },
7385
- enumerable: false,
7386
- configurable: true
7387
- });
7388
- Object.defineProperty(Vehicle.prototype, "personalKilometres", {
7389
- get: function () {
7390
- return this.totalKilometres - this.workKilometres;
7391
- },
7392
- enumerable: false,
7393
- configurable: true
7394
- });
7395
- Object.defineProperty(Vehicle.prototype, "lastLogbook", {
7396
- get: function () {
7397
- if (!this.logbook.length) {
7398
- return { odometerEnd: 0 };
7399
- }
7400
- return this.logbook.slice(-1)[0];
7401
- },
7402
- enumerable: false,
7403
- configurable: true
7404
- });
7508
+ /**
7509
+ * Get vehicle's logbooks as collection
7510
+ */
7511
+ Vehicle.prototype.getLogbooks = function () {
7512
+ return new VehicleLogbookCollection(this.logbook);
7513
+ };
7405
7514
  return Vehicle;
7406
7515
  }(Vehicle$1));
7407
7516
  __decorate([
@@ -7438,19 +7547,70 @@
7438
7547
  enumerable: false,
7439
7548
  configurable: true
7440
7549
  });
7441
- Object.defineProperty(VehicleClaim.prototype, "isLogbookMethod", {
7442
- get: function () {
7443
- return this.method === exports.VehicleClaimMethodEnum.LOGBOOK;
7444
- },
7445
- enumerable: false,
7446
- configurable: true
7447
- });
7550
+ VehicleClaim.prototype.isLogbookMethod = function () {
7551
+ return this.method === exports.VehicleClaimMethodEnum.LOGBOOK;
7552
+ };
7553
+ VehicleClaim.prototype.isKLMsMethod = function () {
7554
+ return this.method === exports.VehicleClaimMethodEnum.KMS;
7555
+ };
7556
+ VehicleClaim.prototype.isWorkTank = function () {
7557
+ return this.tankType === exports.TankTypeEnum.WORK;
7558
+ };
7559
+ VehicleClaim.prototype.isSoleTank = function () {
7560
+ return this.tankType === exports.TankTypeEnum.SOLE;
7561
+ };
7448
7562
  /**
7449
- * Claim amount for Kms method
7563
+ * Claim amount for KLMs method. Exists only for KLMs method.
7450
7564
  */
7451
- VehicleClaim.prototype.getKmsClaimAmount = function (vehicleClaimRate) {
7565
+ VehicleClaim.prototype.getKLMsClaimAmount = function (vehicleClaimRate) {
7566
+ if (!this.isKLMsMethod()) {
7567
+ return 0;
7568
+ }
7452
7569
  return +(this.kilometers * vehicleClaimRate).toFixed(2);
7453
7570
  };
7571
+ /**
7572
+ * Get logbook claim amount. Exists only for logbook method.
7573
+ * ClaimAmount = WorkUsage * transaction/depreciation amount
7574
+ */
7575
+ VehicleClaim.prototype.getLogbookClaimAmount = function (transactions) {
7576
+ var _this = this;
7577
+ if (!this.isLogbookMethod()) {
7578
+ return 0;
7579
+ }
7580
+ var transactionsAmount = transactions
7581
+ .getByTankType(this.tankType)
7582
+ .getVehicleTransactions()
7583
+ // except klms transactions because they needed only for klms method
7584
+ .filter(function (transaction) { return !transaction.chartAccounts.isKLMsByTankType(_this.tankType); })
7585
+ .sumBy('amount');
7586
+ // Math.abs because amount will be negative (because we sum expenses), but we don't want negative percent value
7587
+ return Math.abs(transactionsAmount) * this.workUsage / 100;
7588
+ };
7589
+ /**
7590
+ * Create KLMs transaction based on vehicle claim and vehicle claim rate
7591
+ * @TODO handle on backend: Create klms transaction when vhicle claim created
7592
+ */
7593
+ VehicleClaim.prototype.toTransaction = function (vehicleClaimRate) {
7594
+ return classTransformer.plainToClass(Transaction, {
7595
+ amount: this.kilometers * vehicleClaimRate,
7596
+ source: exports.TransactionSourceEnum.CASH,
7597
+ type: exports.TransactionTypeEnum.DEBIT,
7598
+ taxWithheld: 0,
7599
+ description: 'Klm’s method',
7600
+ date: new Date(new FinancialYear().year + "-06-30"),
7601
+ claimPercent: 100,
7602
+ chartAccounts: {
7603
+ id: this.getKlmsChartAccountsIdByTankType(this.tankType)
7604
+ }
7605
+ });
7606
+ };
7607
+ VehicleClaim.prototype.getKlmsChartAccountsIdByTankType = function (tankType) {
7608
+ if (tankType === void 0) { tankType = this.tankType; }
7609
+ if (tankType === exports.TankTypeEnum.WORK) {
7610
+ return exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK;
7611
+ }
7612
+ return exports.ChartAccountsListEnum.KLMS_TRAVELLED;
7613
+ };
7454
7614
  return VehicleClaim;
7455
7615
  }(VehicleClaim$1));
7456
7616
 
@@ -7505,6 +7665,12 @@
7505
7665
  })
7506
7666
  ], Notification.prototype, "redirectionLink", void 0);
7507
7667
 
7668
+ exports.PdfOrientationEnum = void 0;
7669
+ (function (PdfOrientationEnum) {
7670
+ PdfOrientationEnum["PORTRAIT"] = "portrait";
7671
+ PdfOrientationEnum["LANDSCAPE"] = "landscape";
7672
+ })(exports.PdfOrientationEnum || (exports.PdfOrientationEnum = {}));
7673
+
7508
7674
  /**
7509
7675
  * Calculation form control types
7510
7676
  */
@@ -8365,87 +8531,105 @@
8365
8531
  UserEventSettingFieldEnum["FREQUENCY"] = "frequency";
8366
8532
  })(exports.UserEventSettingFieldEnum || (exports.UserEventSettingFieldEnum = {}));
8367
8533
 
8368
- var AddressService = /** @class */ (function () {
8369
- function AddressService(http, environment) {
8534
+ /**
8535
+ * Enum list of all possible account setup items. Using with [ACCOUNT_SETUP_ITEMS]{@link ACCOUNT_SETUP_ITEMS}
8536
+ */
8537
+ var AccountSetupItemsEnum;
8538
+ (function (AccountSetupItemsEnum) {
8539
+ AccountSetupItemsEnum[AccountSetupItemsEnum["SALARY"] = 0] = "SALARY";
8540
+ AccountSetupItemsEnum[AccountSetupItemsEnum["OTHER_INCOME"] = 1] = "OTHER_INCOME";
8541
+ AccountSetupItemsEnum[AccountSetupItemsEnum["PROPERTY"] = 2] = "PROPERTY";
8542
+ AccountSetupItemsEnum[AccountSetupItemsEnum["BANK_FEEDS"] = 3] = "BANK_FEEDS";
8543
+ AccountSetupItemsEnum[AccountSetupItemsEnum["WORK_LOGBOOK"] = 4] = "WORK_LOGBOOK";
8544
+ AccountSetupItemsEnum[AccountSetupItemsEnum["SOLE_INCOME"] = 5] = "SOLE_INCOME";
8545
+ AccountSetupItemsEnum[AccountSetupItemsEnum["TRANSACTION"] = 6] = "TRANSACTION";
8546
+ })(AccountSetupItemsEnum || (AccountSetupItemsEnum = {}));
8547
+
8548
+ var _a;
8549
+ /**
8550
+ * List of all possible account setup steps
8551
+ */
8552
+ var ACCOUNT_SETUP_ITEMS = (_a = {},
8553
+ _a[AccountSetupItemsEnum.SALARY] = classTransformer.plainToClass(AccountSetupItem, {
8554
+ title: 'Add your work income forecast',
8555
+ description: 'One the most important steps is to add your salary or wage incomes so we can automatically calculate tax withheld and your forecasted tax position.',
8556
+ url: '/client/work-tank/forecasting'
8557
+ }),
8558
+ _a[AccountSetupItemsEnum.OTHER_INCOME] = classTransformer.plainToClass(AccountSetupItem, {
8559
+ title: 'Add any other expected incomes',
8560
+ description: 'To ensure an accurate tax position forecast, add estimates for any other income types, like dividends, interest, trusts, annuities, director payments etc.',
8561
+ url: '/client/work-tank/forecasting'
8562
+ }),
8563
+ _a[AccountSetupItemsEnum.PROPERTY] = classTransformer.plainToClass(AccountSetupItem, {
8564
+ title: 'Add your properties',
8565
+ description: 'Add your properties to seamlessly manage your rental incomes and expenses, whilst tracking your cash position, tax positions and equity forecasts in real time.',
8566
+ url: '/client/property-tank'
8567
+ }),
8568
+ _a[AccountSetupItemsEnum.BANK_FEEDS] = classTransformer.plainToClass(AccountSetupItem, {
8569
+ title: 'Link banks and select accounts',
8570
+ description: 'Link banks to automatically feed your account transactions to save you time and money. Allocating live transactions ensures nothing is missed, lost or forgotten!',
8571
+ url: '/client/bank-feeds'
8572
+ }),
8573
+ _a[AccountSetupItemsEnum.WORK_LOGBOOK] = classTransformer.plainToClass(AccountSetupItem, {
8574
+ title: 'Set up your logbook method',
8575
+ description: 'Do you use your vehicle for work? Select your method and the klms or logbook % to automate accurately all vehicle expenses throughout the year.',
8576
+ url: '/client/work-tank/logbook'
8577
+ }),
8578
+ _a[AccountSetupItemsEnum.SOLE_INCOME] = classTransformer.plainToClass(AccountSetupItem, {
8579
+ title: 'Add your business details',
8580
+ description: 'Add your business details, logo and payment terms to create invoice templates in minutes.',
8581
+ url: '/client/sole-tank/forecasting'
8582
+ }),
8583
+ _a[AccountSetupItemsEnum.TRANSACTION] = classTransformer.plainToClass(AccountSetupItem, {
8584
+ title: 'Allocation transactions',
8585
+ description: 'Select one or multiple transactions, the category from the dropdown and attach your receipt. It’s that simple to capture every possible deduction, and keep organised all throughout the year.',
8586
+ url: '/client/bank-feeds'
8587
+ }),
8588
+ _a);
8589
+
8590
+ /**
8591
+ * @TODO extend rest service when it could work with single objects, not only arrays
8592
+ */
8593
+ var ClientIncomeTypesService = /** @class */ (function () {
8594
+ function ClientIncomeTypesService(http, environment) {
8370
8595
  this.http = http;
8371
8596
  this.environment = environment;
8372
- this.countriesSubject = new rxjs.ReplaySubject(1);
8597
+ this.cacheSubject = new rxjs.ReplaySubject(1);
8373
8598
  }
8374
- AddressService.prototype.getCountries = function () {
8599
+ ClientIncomeTypesService.prototype.get = function () {
8375
8600
  var _this = this;
8376
- if (!this._countries) {
8377
- this.http.get(this.environment.apiV2 + "/countries")
8601
+ if (!this.cache) {
8602
+ this.http.get(this.environment.apiV2 + "/client-income-types")
8378
8603
  .pipe(operators.map(function (response) {
8379
- return response['hydra:member'].map(function (item) { return classTransformer.plainToClass(Country, item); });
8604
+ return classTransformer.plainToClass(ClientIncomeTypes, response['hydra:member'][0], { excludePrefixes: ['@'] });
8380
8605
  }))
8381
- .subscribe(function (countries) {
8382
- _this._countries = countries;
8383
- _this.countriesSubject.next(countries);
8606
+ .subscribe(function (incomeTypes) {
8607
+ _this.cache = incomeTypes;
8608
+ _this.cacheSubject.next(_this.cache);
8384
8609
  });
8385
8610
  }
8386
- return this.countriesSubject.asObservable();
8387
- };
8388
- return AddressService;
8389
- }());
8390
- AddressService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
8391
- AddressService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, providedIn: 'root' });
8392
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, decorators: [{
8393
- type: i0.Injectable,
8394
- args: [{
8395
- providedIn: 'root'
8396
- }]
8397
- }], ctorParameters: function () {
8398
- return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
8399
- type: i0.Inject,
8400
- args: ['environment']
8401
- }] }];
8402
- } });
8403
-
8404
- /**
8405
- * Service to work with assets (documents, receipts, e.t.c.)
8406
- */
8407
- var AssetsService = /** @class */ (function () {
8408
- function AssetsService(http, userSwitcherService, environment) {
8409
- this.http = http;
8410
- this.userSwitcherService = userSwitcherService;
8411
- this.environment = environment;
8412
- this.impersonatedClient = this.userSwitcherService.get();
8413
- }
8414
- /**
8415
- * Get asset link
8416
- * @param asset to get the link for
8417
- */
8418
- AssetsService.prototype.getLink = function (asset) {
8419
- return this.http.get(this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id);
8420
- };
8421
- /**
8422
- * Download asset
8423
- * @param asset which should be downloaded
8424
- * @TODO refactor
8425
- */
8426
- AssetsService.prototype.download = function (asset) {
8427
- return this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id + "/download?bearer=" + localStorage.getItem('token') + (this.impersonatedClient ? "&_switch_user=" + this.impersonatedClient : '');
8611
+ return this.cacheSubject.asObservable();
8428
8612
  };
8429
- // @Todo refactor to event dispatcher
8430
- /**
8431
- * Delete asset
8432
- * @param entityId: id of asset main entity (property, folder, transaction, e.t.c.)
8433
- * @param asset which should be deleted
8434
- */
8435
- AssetsService.prototype.delete = function (entityId, asset) {
8436
- return this.http.delete(this.environment.apiV2 + "/" + asset.entityType + "/" + entityId + "/" + asset.type + "/" + asset.id);
8613
+ ClientIncomeTypesService.prototype.update = function (incomeTypes) {
8614
+ var _this = this;
8615
+ return this.http.put(this.environment.apiV2 + "/client-income-types/" + incomeTypes.id, incomeTypes)
8616
+ .pipe(operators.map(function (incomeTypesBase) {
8617
+ _this.cache = classTransformer.plainToClass(ClientIncomeTypes, incomeTypesBase);
8618
+ _this.cacheSubject.next(_this.cache);
8619
+ return _this.cache;
8620
+ }));
8437
8621
  };
8438
- return AssetsService;
8622
+ return ClientIncomeTypesService;
8439
8623
  }());
8440
- AssetsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, deps: [{ token: i1__namespace.HttpClient }, { token: UserSwitcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
8441
- AssetsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, providedIn: 'root' });
8442
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, decorators: [{
8624
+ ClientIncomeTypesService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ClientIncomeTypesService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
8625
+ ClientIncomeTypesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ClientIncomeTypesService, providedIn: 'root' });
8626
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ClientIncomeTypesService, decorators: [{
8443
8627
  type: i0.Injectable,
8444
8628
  args: [{
8445
8629
  providedIn: 'root'
8446
8630
  }]
8447
8631
  }], ctorParameters: function () {
8448
- return [{ type: i1__namespace.HttpClient }, { type: UserSwitcherService }, { type: undefined, decorators: [{
8632
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
8449
8633
  type: i0.Inject,
8450
8634
  args: ['environment']
8451
8635
  }] }];
@@ -8478,19 +8662,75 @@
8478
8662
  }]
8479
8663
  }] });
8480
8664
 
8665
+ /**
8666
+ * popup notifications service (toast, snackbar).
8667
+ */
8668
+ var ToastService = /** @class */ (function () {
8669
+ function ToastService() {
8670
+ this.toast$ = new rxjs.ReplaySubject(1);
8671
+ }
8672
+ ToastService.prototype.get = function () {
8673
+ return this.toast$.asObservable();
8674
+ };
8675
+ ToastService.prototype.add = function (toast) {
8676
+ this.toast$.next(toast);
8677
+ };
8678
+ ToastService.prototype.success = function (message) {
8679
+ this.add(classTransformer.plainToClass(Toast, {
8680
+ type: exports.ToastTypeEnum.SUCCESS,
8681
+ title: 'Success!',
8682
+ message: message,
8683
+ }));
8684
+ };
8685
+ ToastService.prototype.warning = function (message) {
8686
+ this.add(classTransformer.plainToClass(Toast, {
8687
+ type: exports.ToastTypeEnum.WARNING,
8688
+ title: 'Warning!',
8689
+ message: message,
8690
+ }));
8691
+ };
8692
+ ToastService.prototype.error = function (message) {
8693
+ this.add(classTransformer.plainToClass(Toast, {
8694
+ type: exports.ToastTypeEnum.ERROR,
8695
+ title: 'Error!',
8696
+ message: message,
8697
+ }));
8698
+ };
8699
+ ToastService.prototype.info = function (message) {
8700
+ this.add(classTransformer.plainToClass(Toast, {
8701
+ type: exports.ToastTypeEnum.INFO,
8702
+ title: 'Information',
8703
+ message: message,
8704
+ }));
8705
+ };
8706
+ return ToastService;
8707
+ }());
8708
+ ToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
8709
+ ToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, providedIn: 'root' });
8710
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, decorators: [{
8711
+ type: i0.Injectable,
8712
+ args: [{
8713
+ providedIn: 'root'
8714
+ }]
8715
+ }] });
8716
+
8481
8717
  /**
8482
8718
  * Abstract base service that implements common services functionality
8483
8719
  * and describe abstract methods/properties that have to be implemented in child services
8484
8720
  * Model - entity service is working with
8485
8721
  * BaseModel - base entity model that extends by Model
8722
+ * @TODO Alex: refactor all services for work with collections instead of arrays
8723
+ * @TODO Alex: implement smart system of default toast messages
8486
8724
  */
8487
8725
  var RestService = /** @class */ (function () {
8488
- function RestService(http, eventDispatcherService, environment) {
8726
+ function RestService(http, eventDispatcherService, environment, toastService) {
8489
8727
  this.http = http;
8490
8728
  this.eventDispatcherService = eventDispatcherService;
8491
8729
  this.environment = environment;
8730
+ this.toastService = toastService;
8492
8731
  // subject for service cache
8493
8732
  this.cacheSubject = new rxjs.ReplaySubject(1);
8733
+ this.listenEvents();
8494
8734
  }
8495
8735
  /**
8496
8736
  * get cached list of all instances
@@ -8539,6 +8779,9 @@
8539
8779
  _this.cache.push(newInstance);
8540
8780
  _this.updateCache();
8541
8781
  }
8782
+ if (_this.messageCreated) {
8783
+ _this.toastService.success(_this.messageCreated);
8784
+ }
8542
8785
  return newInstance;
8543
8786
  }));
8544
8787
  };
@@ -8559,6 +8802,9 @@
8559
8802
  (_a = _this.cache).push.apply(_a, __spreadArray([], __read(newInstances)));
8560
8803
  _this.updateCache();
8561
8804
  }
8805
+ if (_this.messageCreatedBatch) {
8806
+ _this.toastService.success(_this.messageCreatedBatch);
8807
+ }
8562
8808
  return newInstances;
8563
8809
  }));
8564
8810
  };
@@ -8576,6 +8822,9 @@
8576
8822
  var updatedInstance = _this.createModelInstance(_this.modelClass, updatedItem);
8577
8823
  replace(_this.cache, updatedInstance);
8578
8824
  _this.updateCache();
8825
+ if (_this.messageUpdated) {
8826
+ _this.toastService.success(_this.messageUpdated);
8827
+ }
8579
8828
  return updatedInstance;
8580
8829
  }));
8581
8830
  };
@@ -8594,6 +8843,9 @@
8594
8843
  updatedInstances.forEach(function (instance) {
8595
8844
  replace(_this.cache, instance);
8596
8845
  });
8846
+ if (_this.messageUpdatedBatch) {
8847
+ _this.toastService.success(_this.messageUpdatedBatch);
8848
+ }
8597
8849
  _this.updateCache();
8598
8850
  return updatedInstances;
8599
8851
  }));
@@ -8608,6 +8860,9 @@
8608
8860
  .pipe(operators.map(function () {
8609
8861
  _this.cache = _this.cache.filter(function (item) { return item['id'] !== model['id']; });
8610
8862
  _this.updateCache();
8863
+ if (_this.messageDeleted) {
8864
+ _this.toastService.success(_this.messageDeleted);
8865
+ }
8611
8866
  }));
8612
8867
  };
8613
8868
  /**
@@ -8621,6 +8876,9 @@
8621
8876
  var ids = models.map(function (model) { return model['id']; });
8622
8877
  _this.cache = _this.cache.filter(function (item) { return !ids.includes(item['id']); });
8623
8878
  _this.updateCache();
8879
+ if (_this.messageDeletedBatch) {
8880
+ _this.toastService.success(_this.messageDeletedBatch);
8881
+ }
8624
8882
  }));
8625
8883
  };
8626
8884
  /**
@@ -8659,9 +8917,13 @@
8659
8917
  RestService.prototype.createModelInstance = function (model, baseModel) {
8660
8918
  return classTransformer.plainToClass(model, baseModel, { excludePrefixes: ['@'] });
8661
8919
  };
8662
- return RestService;
8920
+ /**
8921
+ * Method that call all listeners. Empty by default. Should be redefined by child services if required
8922
+ */
8923
+ RestService.prototype.listenEvents = function () { };
8924
+ return RestService;
8663
8925
  }());
8664
- RestService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RestService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
8926
+ RestService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RestService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
8665
8927
  RestService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RestService, providedIn: 'root' });
8666
8928
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RestService, decorators: [{
8667
8929
  type: i0.Injectable,
@@ -8672,26 +8934,217 @@
8672
8934
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
8673
8935
  type: i0.Inject,
8674
8936
  args: ['environment']
8675
- }] }];
8937
+ }] }, { type: ToastService }];
8676
8938
  } });
8677
8939
 
8678
8940
  /**
8679
- * Service that handling banks logic
8941
+ * Service for work with Property
8680
8942
  */
8681
- var BankService = /** @class */ (function (_super) {
8682
- __extends(BankService, _super);
8683
- function BankService() {
8943
+ var PropertyService = /** @class */ (function (_super) {
8944
+ __extends(PropertyService, _super);
8945
+ function PropertyService() {
8684
8946
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
8685
- _this.modelClass = Bank;
8686
- _this.url = 'banks';
8687
- _this.isHydra = true;
8947
+ _this.modelClass = Property;
8948
+ _this.url = 'properties';
8688
8949
  return _this;
8689
8950
  }
8690
- return BankService;
8951
+ PropertyService.prototype.listenEvents = function () {
8952
+ this.listenShareInviteAccepted();
8953
+ this.listenServiceSubscriptionUpdated();
8954
+ // @TODO Alex: consider to refactor property movements logic similar to client-movements
8955
+ this.listenMovementsChanged();
8956
+ };
8957
+ /**
8958
+ * Update cache when share invitation accepted
8959
+ */
8960
+ PropertyService.prototype.listenShareInviteAccepted = function () {
8961
+ var _this = this;
8962
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(function () { return _this.resetCache(); });
8963
+ };
8964
+ /**
8965
+ * Update cache when user's service subscription is updated
8966
+ */
8967
+ PropertyService.prototype.listenServiceSubscriptionUpdated = function () {
8968
+ var _this = this;
8969
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
8970
+ };
8971
+ /**
8972
+ * Update cache when property category changed
8973
+ */
8974
+ PropertyService.prototype.listenMovementsChanged = function () {
8975
+ var _this = this;
8976
+ // @TODO change dispatcher logic to work with multiple events
8977
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED).subscribe(function () { return _this.resetCache(); });
8978
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_UPDATED).subscribe(function () { return _this.resetCache(); });
8979
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_DELETED).subscribe(function () { return _this.resetCache(); });
8980
+ };
8981
+ PropertyService.prototype.update = function (property) {
8982
+ var _this = this;
8983
+ return _super.prototype.update.call(this, property).pipe(operators.map(function (updatedProperty) {
8984
+ if (property.documentFile) {
8985
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_UPDATED_WITH_DOCUMENT, property));
8986
+ }
8987
+ return updatedProperty;
8988
+ }));
8989
+ };
8990
+ PropertyService.prototype.getByCategoryId = function (id) {
8991
+ return this.get().pipe(operators.map(function (properties) {
8992
+ return properties.filter(function (property) { return property.category.id === id; });
8993
+ }));
8994
+ };
8995
+ /**
8996
+ * Activate deactivated property
8997
+ */
8998
+ PropertyService.prototype.activate = function (property) {
8999
+ var _this = this;
9000
+ return this.http.post(this.environment.apiV2 + "/property-subscriptions", { user: property.user, property: property })
9001
+ .pipe(operators.map(function (propertySubscriptionBase) {
9002
+ var newPropertySubscription = classTransformer.plainToClass(PropertySubscription, propertySubscriptionBase);
9003
+ var activatedProperty = classTransformer.plainToClass(Property, Object.assign({}, property, { subscriptions: [newPropertySubscription] }));
9004
+ replace(_this.cache, activatedProperty);
9005
+ _this.updateCache();
9006
+ }));
9007
+ };
9008
+ /**
9009
+ * Deactivate activated property
9010
+ */
9011
+ PropertyService.prototype.deactivate = function (property) {
9012
+ var _this = this;
9013
+ return this.http.delete(this.environment.apiV2 + "/property-subscriptions/" + property.getCurrentSubscription().id)
9014
+ .pipe(operators.map(function () {
9015
+ var deactivatedProperty = classTransformer.plainToClass(Property, Object.assign({}, property, { subscriptions: [] }));
9016
+ replace(_this.cache, deactivatedProperty);
9017
+ _this.updateCache();
9018
+ }));
9019
+ };
9020
+ /**
9021
+ * Update property photo
9022
+ * @param property Property instance for photo update
9023
+ * @param photoFormData FormData with property photo image
9024
+ */
9025
+ PropertyService.prototype.updatePhoto = function (property, photoFormData) {
9026
+ var _this = this;
9027
+ return this.http.post(this.environment.apiV2 + "/properties/" + property.id + "/photo?_method=PUT", photoFormData)
9028
+ .pipe(operators.map(function (photoLink) {
9029
+ property.photo = photoLink;
9030
+ // update properties cache
9031
+ replace(_this.cache, property);
9032
+ _this.updateCache();
9033
+ }));
9034
+ };
9035
+ PropertyService.prototype.getByShareId = function (id) {
9036
+ return this.get().pipe(operators.map(function (properties) {
9037
+ return properties.filter(function (property) { return property.user.id === id; });
9038
+ }));
9039
+ };
9040
+ /**
9041
+ * Get list of active user's properties
9042
+ */
9043
+ PropertyService.prototype.getActive = function () {
9044
+ return this.get().pipe(operators.map(function (properties) { return properties.filter(function (property) { return property.isActive; }); }));
9045
+ };
9046
+ return PropertyService;
8691
9047
  }(RestService));
8692
- BankService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
8693
- BankService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, providedIn: 'root' });
8694
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, decorators: [{
9048
+ PropertyService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9049
+ PropertyService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyService, providedIn: 'root' });
9050
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyService, decorators: [{
9051
+ type: i0.Injectable,
9052
+ args: [{
9053
+ providedIn: 'root'
9054
+ }]
9055
+ }] });
9056
+
9057
+ /**
9058
+ * Service to work with income sources
9059
+ */
9060
+ var IncomeSourceService = /** @class */ (function (_super) {
9061
+ __extends(IncomeSourceService, _super);
9062
+ function IncomeSourceService() {
9063
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9064
+ _this.url = 'income-sources';
9065
+ _this.modelClass = IncomeSource;
9066
+ _this.incomeSourceTypeSubject = new rxjs.ReplaySubject(1);
9067
+ return _this;
9068
+ }
9069
+ /**
9070
+ * Get income sources tax calculation
9071
+ * @param salaryForecast for which tax should be calculated
9072
+ */
9073
+ IncomeSourceService.prototype.getTaxCalculation = function (salaryForecast) {
9074
+ return this.http.post(this.environment.apiV2 + "/" + this.url + "/tax-calculation", salaryForecast)
9075
+ .pipe(operators.map(function (response) {
9076
+ return classTransformer.plainToClass(SalaryForecast, response);
9077
+ }));
9078
+ };
9079
+ /**
9080
+ * Add batch of income sources
9081
+ * @param incomeSources to add
9082
+ */
9083
+ IncomeSourceService.prototype.addBatch = function (incomeSources) {
9084
+ var _this = this;
9085
+ return this.http.post(this.environment.apiV2 + "/" + this.url, incomeSources)
9086
+ .pipe(operators.map(function (addedIncomeSources) {
9087
+ var _a;
9088
+ // assign respond income sources to provided income sources
9089
+ var assignedIncomeSources = addedIncomeSources
9090
+ .map(function (incomeSource, index) { return Object.assign(classTransformer.plainToClass(IncomeSource, {}), incomeSource, incomeSources[index]); });
9091
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.INCOME_SOURCES_CREATED, assignedIncomeSources));
9092
+ (_a = _this.cache).push.apply(_a, __spreadArray([], __read(assignedIncomeSources)));
9093
+ _this.updateCache();
9094
+ return assignedIncomeSources;
9095
+ }));
9096
+ };
9097
+ /**
9098
+ * Update batch of income sources
9099
+ */
9100
+ IncomeSourceService.prototype.updateBatch = function (incomeSources, queryParams) {
9101
+ var _this = this;
9102
+ if (queryParams === void 0) { queryParams = {}; }
9103
+ return this.http.put(this.environment.apiV2 + "/" + this.url, incomeSources, queryParams)
9104
+ .pipe(operators.map(function (updatedItems) {
9105
+ var updatedInstances = updatedItems.map(function (item) { return _this.createModelInstance(_this.modelClass, item); });
9106
+ updatedInstances.forEach(function (instance) {
9107
+ replace(_this.cache, instance);
9108
+ });
9109
+ if (incomeSources[0].forecasts.length) {
9110
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.INCOME_SOURCES_UPDATED, incomeSources));
9111
+ }
9112
+ _this.updateCache();
9113
+ return updatedInstances;
9114
+ }));
9115
+ };
9116
+ /**
9117
+ * Get income sources by provided types
9118
+ * @param types
9119
+ */
9120
+ IncomeSourceService.prototype.getByTypes = function (types) {
9121
+ return this.get()
9122
+ .pipe(operators.map(function (incomeSources) { return incomeSources
9123
+ .filter(function (incomeSource) { return types.includes(incomeSource.type); }); }));
9124
+ };
9125
+ /**
9126
+ * Get other incomes types
9127
+ */
9128
+ IncomeSourceService.prototype.getIncomeSourceTypes = function () {
9129
+ var _this = this;
9130
+ if (!this.incomeSourceTypes) {
9131
+ this.incomeSourceTypes = [];
9132
+ this.http.get(this.environment.apiV2 + "/income-source-types")
9133
+ .pipe(operators.map(function (response) {
9134
+ return response.map(function (item) { return classTransformer.plainToClass(IncomeSourceType, item); });
9135
+ }))
9136
+ .subscribe(function (otherIncomesTypes) {
9137
+ _this.incomeSourceTypes = otherIncomesTypes;
9138
+ _this.incomeSourceTypeSubject.next(_this.incomeSourceTypes);
9139
+ });
9140
+ }
9141
+ return this.incomeSourceTypeSubject.asObservable();
9142
+ };
9143
+ return IncomeSourceService;
9144
+ }(RestService));
9145
+ IncomeSourceService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9146
+ IncomeSourceService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceService, providedIn: 'root' });
9147
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceService, decorators: [{
8695
9148
  type: i0.Injectable,
8696
9149
  args: [{
8697
9150
  providedIn: 'root'
@@ -8703,15 +9156,11 @@
8703
9156
  */
8704
9157
  var BankAccountService = /** @class */ (function (_super) {
8705
9158
  __extends(BankAccountService, _super);
8706
- function BankAccountService(http, eventDispatcherService, environment) {
8707
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
8708
- _this.http = http;
8709
- _this.eventDispatcherService = eventDispatcherService;
8710
- _this.environment = environment;
9159
+ function BankAccountService() {
9160
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
8711
9161
  // api url parameter for bank accounts
8712
9162
  _this.url = 'bank-accounts';
8713
9163
  _this.modelClass = BankAccount;
8714
- _this.listenEvents();
8715
9164
  return _this;
8716
9165
  }
8717
9166
  /**
@@ -8784,37 +9233,348 @@
8784
9233
  }));
8785
9234
  };
8786
9235
  /**
8787
- * Listen to EventDispatcherService events
9236
+ * Listen to EventDispatcherService events
9237
+ */
9238
+ BankAccountService.prototype.listenToEventDispatcherChanges = function () {
9239
+ var _this = this;
9240
+ this.eventDispatcherService.on([
9241
+ exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED,
9242
+ exports.AppEventTypeEnum.LOAN_PAYOUT_UPDATED,
9243
+ exports.AppEventTypeEnum.BANK_CONNECTION_ADDED
9244
+ ]).subscribe(function () {
9245
+ _this.fetch().subscribe(function (bankAccounts) {
9246
+ _this.cache = bankAccounts;
9247
+ _this.updateCache();
9248
+ });
9249
+ });
9250
+ };
9251
+ return BankAccountService;
9252
+ }(RestService));
9253
+ BankAccountService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9254
+ BankAccountService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountService, providedIn: 'root' });
9255
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountService, decorators: [{
9256
+ type: i0.Injectable,
9257
+ args: [{
9258
+ providedIn: 'root'
9259
+ }]
9260
+ }] });
9261
+
9262
+ // @TODO Don't look at the commented code. Will be refactored/removed during TT-1503
9263
+ /**
9264
+ * Service for transaction allocations business logic
9265
+ * @TODO alex refactor
9266
+ */
9267
+ var TransactionAllocationService = /** @class */ (function (_super) {
9268
+ __extends(TransactionAllocationService, _super);
9269
+ function TransactionAllocationService() {
9270
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9271
+ // API URL param for transaction allocations
9272
+ _this.url = 'transactions-allocations';
9273
+ _this.modelClass = TransactionAllocation;
9274
+ return _this;
9275
+ }
9276
+ /**
9277
+ * Add single transaction allocation
9278
+ */
9279
+ TransactionAllocationService.prototype.add = function (allocation) {
9280
+ return this.addBatch([allocation]).pipe(operators.map(function (newAllocations) { return newAllocations[0]; }));
9281
+ };
9282
+ /**
9283
+ * get list of transactions allocations related with passed bank transactions list
9284
+ */
9285
+ TransactionAllocationService.prototype.getByTransactions = function (transactions) {
9286
+ var ids = transactions.map(function (transaction) { return transaction.id; });
9287
+ return this.get()
9288
+ .pipe(operators.map(function (transactionAllocations) {
9289
+ return transactionAllocations.filter(function (allocation) { return ids.includes(allocation.transaction.id); });
9290
+ }));
9291
+ };
9292
+ TransactionAllocationService.prototype.listenEvents = function () {
9293
+ this.onTransactionsCreated();
9294
+ this.onDepreciationCreated();
9295
+ this.onTransactionDeleted();
9296
+ };
9297
+ /**
9298
+ * Reset cache on transactions created
9299
+ */
9300
+ TransactionAllocationService.prototype.onTransactionsCreated = function () {
9301
+ var _this = this;
9302
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe(function () {
9303
+ // Update allocations cache to synchronize data and fire subscriptions
9304
+ _this.resetCache();
9305
+ });
9306
+ };
9307
+ /**
9308
+ * Reset cache on depreciation created
9309
+ */
9310
+ TransactionAllocationService.prototype.onDepreciationCreated = function () {
9311
+ var _this = this;
9312
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATIONS_CREATED).subscribe(function () {
9313
+ // Update allocations cache to synchronize data and fire subscriptions
9314
+ _this.resetCache();
9315
+ });
9316
+ };
9317
+ /**
9318
+ * Reset cache on transaction deleted
9319
+ */
9320
+ TransactionAllocationService.prototype.onTransactionDeleted = function () {
9321
+ var _this = this;
9322
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_DELETED).subscribe(function () {
9323
+ // Update allocations cache to synchronize data and fire subscriptions
9324
+ _this.resetCache();
9325
+ });
9326
+ };
9327
+ return TransactionAllocationService;
9328
+ }(RestService));
9329
+ TransactionAllocationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionAllocationService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9330
+ TransactionAllocationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionAllocationService, providedIn: 'root' });
9331
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionAllocationService, decorators: [{
9332
+ type: i0.Injectable,
9333
+ args: [{
9334
+ providedIn: 'root'
9335
+ }]
9336
+ }] });
9337
+
9338
+ var MessagesEnum$1;
9339
+ (function (MessagesEnum) {
9340
+ MessagesEnum["VEHICLE_CREATED"] = "Vehicle created successfully";
9341
+ MessagesEnum["VEHICLE_UPDATED"] = "Vehicle updated successfully";
9342
+ MessagesEnum["VEHICLE_DELETED"] = "Vehicle deleted successfully";
9343
+ MessagesEnum["VEHICLE_CLAIM_CREATED"] = "Vehicle claim created successfully";
9344
+ MessagesEnum["VEHICLE_CLAIM_UPDATED"] = "Vehicle claim updated successfully";
9345
+ MessagesEnum["VEHICLE_CLAIM_DELETED"] = "Vehicle claim deleted successfully";
9346
+ MessagesEnum["VEHICLE_LOGBOOK_CREATED"] = "Vehicle logbook created successfully";
9347
+ MessagesEnum["VEHICLE_LOGBOOK_UPDATED"] = "Vehicle logbook updated successfully";
9348
+ MessagesEnum["VEHICLE_LOGBOOK_DELETED"] = "Vehicle logbook deleted successfully";
9349
+ })(MessagesEnum$1 || (MessagesEnum$1 = {}));
9350
+
9351
+ var VehicleClaimService = /** @class */ (function (_super) {
9352
+ __extends(VehicleClaimService, _super);
9353
+ function VehicleClaimService() {
9354
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9355
+ _this.modelClass = VehicleClaim;
9356
+ _this.url = 'vehicle-claims';
9357
+ _this.messageCreated = MessagesEnum$1.VEHICLE_CLAIM_CREATED;
9358
+ _this.messageUpdated = MessagesEnum$1.VEHICLE_CLAIM_UPDATED;
9359
+ _this.messageDeleted = MessagesEnum$1.VEHICLE_CLAIM_DELETED;
9360
+ return _this;
9361
+ }
9362
+ return VehicleClaimService;
9363
+ }(RestService));
9364
+ VehicleClaimService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleClaimService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9365
+ VehicleClaimService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleClaimService, providedIn: 'root' });
9366
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleClaimService, decorators: [{
9367
+ type: i0.Injectable,
9368
+ args: [{
9369
+ providedIn: 'root'
9370
+ }]
9371
+ }] });
9372
+
9373
+ /**
9374
+ * Service handling user's account setup process.
9375
+ * Checks required steps and their completion
9376
+ */
9377
+ var AccountSetupService = /** @class */ (function () {
9378
+ function AccountSetupService(clientIncomeTypesService, propertyService, incomeSourceService, bankAccountsService, transactionAllocationService, vehicleClaimService) {
9379
+ this.clientIncomeTypesService = clientIncomeTypesService;
9380
+ this.propertyService = propertyService;
9381
+ this.incomeSourceService = incomeSourceService;
9382
+ this.bankAccountsService = bankAccountsService;
9383
+ this.transactionAllocationService = transactionAllocationService;
9384
+ this.vehicleClaimService = vehicleClaimService;
9385
+ this.cacheSubject = new rxjs.ReplaySubject(1);
9386
+ }
9387
+ /**
9388
+ * Get list of account setup items for current user
9389
+ */
9390
+ AccountSetupService.prototype.get = function () {
9391
+ var _this = this;
9392
+ if (!this.cache) {
9393
+ this.clientIncomeTypesService.get().subscribe(function (incomeTypes) {
9394
+ rxjs.combineLatest(_this.createBatch(incomeTypes)).subscribe(function (items) {
9395
+ _this.cache = new AccountSetupItemCollection(items);
9396
+ _this.cacheSubject.next(_this.cache);
9397
+ });
9398
+ });
9399
+ }
9400
+ return this.cacheSubject.asObservable();
9401
+ };
9402
+ /**
9403
+ * Get a single AccountSetupItem and check it's completion
9404
+ */
9405
+ AccountSetupService.prototype.create = function (itemType, request) {
9406
+ return request.pipe(operators.map(function (result) {
9407
+ var item = ACCOUNT_SETUP_ITEMS[itemType];
9408
+ if (result.length) {
9409
+ item.isCompleted = true;
9410
+ }
9411
+ return item;
9412
+ }));
9413
+ };
9414
+ /**
9415
+ * Get batch of requests to get list of required AccountSetupItem's.
9416
+ * Some items are optional and depends of user's client income types
9417
+ */
9418
+ AccountSetupService.prototype.createBatch = function (incomeTypes) {
9419
+ var batch = [];
9420
+ // Salary item is completed when user added salary income source
9421
+ if (incomeTypes.salary) {
9422
+ batch.push(this.create(AccountSetupItemsEnum.SALARY, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.SALARY)));
9423
+ }
9424
+ // Other income item is completed when user added at least one other income source
9425
+ if (incomeTypes.dividends || incomeTypes.other) {
9426
+ batch.push(this.create(AccountSetupItemsEnum.OTHER_INCOME, this.getIncomeSourcesByType(exports.IncomeSourceTypeEnum.OTHER)));
9427
+ }
9428
+ // Rental income item is completed when user added at least one property
9429
+ if (incomeTypes.rental) {
9430
+ batch.push(this.create(AccountSetupItemsEnum.PROPERTY, this.propertyService.get()));
9431
+ }
9432
+ // Bank feeds item is completed when user added at least one bank account (basiq or manual)
9433
+ batch.push(this.create(AccountSetupItemsEnum.BANK_FEEDS, this.bankAccountsService.get()));
9434
+ // Logbook item is completed when user has at least one vehicle claim with any method (klms or logbook)
9435
+ batch.push(this.create(AccountSetupItemsEnum.WORK_LOGBOOK, this.vehicleClaimService.get()));
9436
+ // @TODO waiting for sole tank forecast page
9437
+ // Sole item is completed when user added at least one sole income source
9438
+ // if (incomeTypes.soleTrader) {
9439
+ // batch.push(
9440
+ // this.prepareItem(
9441
+ // AccountSetupItemsEnum.SOLE_INCOME,
9442
+ // this.getIncomeSourcesByType(IncomeSourceTypeEnum.SOLE)
9443
+ // )
9444
+ // );
9445
+ // }
9446
+ // Allocation item is completed when user added at least one transaction allocation
9447
+ batch.push(this.create(AccountSetupItemsEnum.TRANSACTION, this.transactionAllocationService.get()));
9448
+ return batch;
9449
+ };
9450
+ /**
9451
+ * @TODO work with collection when services refactored
9452
+ */
9453
+ AccountSetupService.prototype.getIncomeSourcesByType = function (type) {
9454
+ return this.incomeSourceService.get().pipe(operators.map(function (incomeSources) {
9455
+ return new IncomeSourceCollection(incomeSources).getBy('type', type).toArray();
9456
+ }));
9457
+ };
9458
+ return AccountSetupService;
9459
+ }());
9460
+ AccountSetupService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, deps: [{ token: ClientIncomeTypesService }, { token: PropertyService }, { token: IncomeSourceService }, { token: BankAccountService }, { token: TransactionAllocationService }, { token: VehicleClaimService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9461
+ AccountSetupService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, providedIn: 'root' });
9462
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AccountSetupService, decorators: [{
9463
+ type: i0.Injectable,
9464
+ args: [{
9465
+ providedIn: 'root'
9466
+ }]
9467
+ }], ctorParameters: function () { return [{ type: ClientIncomeTypesService }, { type: PropertyService }, { type: IncomeSourceService }, { type: BankAccountService }, { type: TransactionAllocationService }, { type: VehicleClaimService }]; } });
9468
+
9469
+ var AddressService = /** @class */ (function () {
9470
+ function AddressService(http, environment) {
9471
+ this.http = http;
9472
+ this.environment = environment;
9473
+ this.countriesSubject = new rxjs.ReplaySubject(1);
9474
+ }
9475
+ AddressService.prototype.getCountries = function () {
9476
+ var _this = this;
9477
+ if (!this._countries) {
9478
+ this.http.get(this.environment.apiV2 + "/countries")
9479
+ .pipe(operators.map(function (response) {
9480
+ return response['hydra:member'].map(function (item) { return classTransformer.plainToClass(Country, item); });
9481
+ }))
9482
+ .subscribe(function (countries) {
9483
+ _this._countries = countries;
9484
+ _this.countriesSubject.next(countries);
9485
+ });
9486
+ }
9487
+ return this.countriesSubject.asObservable();
9488
+ };
9489
+ return AddressService;
9490
+ }());
9491
+ AddressService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9492
+ AddressService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, providedIn: 'root' });
9493
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AddressService, decorators: [{
9494
+ type: i0.Injectable,
9495
+ args: [{
9496
+ providedIn: 'root'
9497
+ }]
9498
+ }], ctorParameters: function () {
9499
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
9500
+ type: i0.Inject,
9501
+ args: ['environment']
9502
+ }] }];
9503
+ } });
9504
+
9505
+ /**
9506
+ * Service to work with assets (documents, receipts, e.t.c.)
9507
+ */
9508
+ var AssetsService = /** @class */ (function () {
9509
+ function AssetsService(http, userSwitcherService, environment) {
9510
+ this.http = http;
9511
+ this.userSwitcherService = userSwitcherService;
9512
+ this.environment = environment;
9513
+ this.impersonatedClient = this.userSwitcherService.get();
9514
+ }
9515
+ /**
9516
+ * Get asset link
9517
+ * @param asset to get the link for
9518
+ */
9519
+ AssetsService.prototype.getLink = function (asset) {
9520
+ return this.http.get(this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id);
9521
+ };
9522
+ /**
9523
+ * Download asset
9524
+ * @param asset which should be downloaded
9525
+ * @TODO refactor
9526
+ */
9527
+ AssetsService.prototype.download = function (asset) {
9528
+ return this.environment.apiV2 + "/assets/" + asset.type + "/" + asset.id + "/download?bearer=" + localStorage.getItem('token') + (this.impersonatedClient ? "&_switch_user=" + this.impersonatedClient : '');
9529
+ };
9530
+ // @Todo refactor to event dispatcher
9531
+ /**
9532
+ * Delete asset
9533
+ * @param entityId: id of asset main entity (property, folder, transaction, e.t.c.)
9534
+ * @param asset which should be deleted
8788
9535
  */
8789
- BankAccountService.prototype.listenToEventDispatcherChanges = function () {
8790
- var _this = this;
8791
- this.eventDispatcherService.on([
8792
- exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED,
8793
- exports.AppEventTypeEnum.LOAN_PAYOUT_UPDATED,
8794
- exports.AppEventTypeEnum.BANK_CONNECTION_ADDED
8795
- ]).subscribe(function () {
8796
- _this.fetch().subscribe(function (bankAccounts) {
8797
- _this.cache = bankAccounts;
8798
- _this.updateCache();
8799
- });
8800
- });
9536
+ AssetsService.prototype.delete = function (entityId, asset) {
9537
+ return this.http.delete(this.environment.apiV2 + "/" + asset.entityType + "/" + entityId + "/" + asset.type + "/" + asset.id);
8801
9538
  };
8802
- return BankAccountService;
8803
- }(RestService));
8804
- BankAccountService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
8805
- BankAccountService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountService, providedIn: 'root' });
8806
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankAccountService, decorators: [{
9539
+ return AssetsService;
9540
+ }());
9541
+ AssetsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, deps: [{ token: i1__namespace.HttpClient }, { token: UserSwitcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9542
+ AssetsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, providedIn: 'root' });
9543
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: AssetsService, decorators: [{
8807
9544
  type: i0.Injectable,
8808
9545
  args: [{
8809
9546
  providedIn: 'root'
8810
9547
  }]
8811
9548
  }], ctorParameters: function () {
8812
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9549
+ return [{ type: i1__namespace.HttpClient }, { type: UserSwitcherService }, { type: undefined, decorators: [{
8813
9550
  type: i0.Inject,
8814
9551
  args: ['environment']
8815
9552
  }] }];
8816
9553
  } });
8817
9554
 
9555
+ /**
9556
+ * Service that handling banks logic
9557
+ */
9558
+ var BankService = /** @class */ (function (_super) {
9559
+ __extends(BankService, _super);
9560
+ function BankService() {
9561
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9562
+ _this.modelClass = Bank;
9563
+ _this.url = 'banks';
9564
+ _this.isHydra = true;
9565
+ return _this;
9566
+ }
9567
+ return BankService;
9568
+ }(RestService));
9569
+ BankService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9570
+ BankService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, providedIn: 'root' });
9571
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, decorators: [{
9572
+ type: i0.Injectable,
9573
+ args: [{
9574
+ providedIn: 'root'
9575
+ }]
9576
+ }] });
9577
+
8818
9578
  /**
8819
9579
  * @TODO move to collection
8820
9580
  */
@@ -8916,14 +9676,10 @@
8916
9676
  */
8917
9677
  var BankConnectionService = /** @class */ (function (_super) {
8918
9678
  __extends(BankConnectionService, _super);
8919
- function BankConnectionService(http, eventDispatcherService, environment) {
8920
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
8921
- _this.http = http;
8922
- _this.eventDispatcherService = eventDispatcherService;
8923
- _this.environment = environment;
9679
+ function BankConnectionService() {
9680
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
8924
9681
  _this.modelClass = BankConnection;
8925
9682
  _this.url = 'bank-connections';
8926
- _this.listenEvents();
8927
9683
  return _this;
8928
9684
  }
8929
9685
  BankConnectionService.prototype.listenEvents = function () {
@@ -8945,34 +9701,25 @@
8945
9701
  };
8946
9702
  return BankConnectionService;
8947
9703
  }(RestService));
8948
- BankConnectionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9704
+ BankConnectionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
8949
9705
  BankConnectionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, providedIn: 'root' });
8950
9706
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankConnectionService, decorators: [{
8951
9707
  type: i0.Injectable,
8952
9708
  args: [{
8953
9709
  providedIn: 'root'
8954
9710
  }]
8955
- }], ctorParameters: function () {
8956
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
8957
- type: i0.Inject,
8958
- args: ['environment']
8959
- }] }];
8960
- } });
9711
+ }] });
8961
9712
 
8962
9713
  /**
8963
9714
  * Service for bank transactions business logic
8964
9715
  */
8965
9716
  var BankTransactionService = /** @class */ (function (_super) {
8966
9717
  __extends(BankTransactionService, _super);
8967
- function BankTransactionService(http, eventDispatcherService, environment) {
8968
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
8969
- _this.http = http;
8970
- _this.eventDispatcherService = eventDispatcherService;
8971
- _this.environment = environment;
9718
+ function BankTransactionService() {
9719
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
8972
9720
  // url part for BankTransaction API
8973
9721
  _this.url = 'bank-transactions';
8974
9722
  _this.modelClass = BankTransaction;
8975
- _this.listenEvents();
8976
9723
  return _this;
8977
9724
  }
8978
9725
  BankTransactionService.prototype.listenEvents = function () {
@@ -9031,19 +9778,14 @@
9031
9778
  };
9032
9779
  return BankTransactionService;
9033
9780
  }(RestService));
9034
- BankTransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9781
+ BankTransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9035
9782
  BankTransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, providedIn: 'root' });
9036
9783
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankTransactionService, decorators: [{
9037
9784
  type: i0.Injectable,
9038
9785
  args: [{
9039
9786
  providedIn: 'root'
9040
9787
  }]
9041
- }], ctorParameters: function () {
9042
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9043
- type: i0.Inject,
9044
- args: ['environment']
9045
- }] }];
9046
- } });
9788
+ }] });
9047
9789
 
9048
9790
  /**
9049
9791
  * basiq is a middleman between bank and user
@@ -9051,15 +9793,11 @@
9051
9793
  */
9052
9794
  var BasiqService = /** @class */ (function (_super) {
9053
9795
  __extends(BasiqService, _super);
9054
- function BasiqService(http, eventDispatcherService, environment) {
9055
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
9056
- _this.http = http;
9057
- _this.eventDispatcherService = eventDispatcherService;
9058
- _this.environment = environment;
9796
+ function BasiqService() {
9797
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9059
9798
  _this.tokenSubject = new rxjs.ReplaySubject();
9060
9799
  _this.url = 'basiq/accounts';
9061
9800
  _this.modelClass = BankAccount;
9062
- _this.listenEvents();
9063
9801
  return _this;
9064
9802
  }
9065
9803
  /**
@@ -9122,19 +9860,14 @@
9122
9860
  };
9123
9861
  return BasiqService;
9124
9862
  }(RestService));
9125
- BasiqService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9863
+ BasiqService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9126
9864
  BasiqService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqService, providedIn: 'root' });
9127
9865
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BasiqService, decorators: [{
9128
9866
  type: i0.Injectable,
9129
9867
  args: [{
9130
9868
  providedIn: 'root'
9131
9869
  }]
9132
- }], ctorParameters: function () {
9133
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9134
- type: i0.Inject,
9135
- args: ['environment']
9136
- }] }];
9137
- } });
9870
+ }] });
9138
9871
 
9139
9872
  var BorrowingExpenseService = /** @class */ (function () {
9140
9873
  function BorrowingExpenseService(http, environment) {
@@ -9374,24 +10107,19 @@
9374
10107
  */
9375
10108
  var ChatService = /** @class */ (function (_super) {
9376
10109
  __extends(ChatService, _super);
9377
- function ChatService(http, eventDispatcherService, environment, sseService) {
9378
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10110
+ function ChatService(http, eventDispatcherService, environment, toastService, sseService) {
10111
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
9379
10112
  _this.http = http;
9380
10113
  _this.eventDispatcherService = eventDispatcherService;
9381
10114
  _this.environment = environment;
10115
+ _this.toastService = toastService;
9382
10116
  _this.sseService = sseService;
9383
10117
  _this.modelClass = Chat;
9384
10118
  _this.url = 'chats';
9385
10119
  _this.isHydra = true;
9386
- _this.listenEvents();
10120
+ _this.listenChats();
9387
10121
  return _this;
9388
10122
  }
9389
- /**
9390
- * SSE and Event Dispatcher Services listeners
9391
- */
9392
- ChatService.prototype.listenEvents = function () {
9393
- this.listenChats();
9394
- };
9395
10123
  /**
9396
10124
  * Listen chats events
9397
10125
  */
@@ -9428,7 +10156,7 @@
9428
10156
  };
9429
10157
  return ChatService;
9430
10158
  }(RestService));
9431
- ChatService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ChatService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: SseService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10159
+ ChatService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ChatService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: SseService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9432
10160
  ChatService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ChatService, providedIn: 'root' });
9433
10161
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ChatService, decorators: [{
9434
10162
  type: i0.Injectable,
@@ -9439,7 +10167,7 @@
9439
10167
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9440
10168
  type: i0.Inject,
9441
10169
  args: ['environment']
9442
- }] }, { type: SseService }];
10170
+ }] }, { type: ToastService }, { type: SseService }];
9443
10171
  } });
9444
10172
 
9445
10173
  /**
@@ -9447,24 +10175,19 @@
9447
10175
  */
9448
10176
  var MessageService = /** @class */ (function (_super) {
9449
10177
  __extends(MessageService, _super);
9450
- function MessageService(http, eventDispatcherService, environment, sseService) {
9451
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10178
+ function MessageService(http, eventDispatcherService, environment, toastService, sseService) {
10179
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
9452
10180
  _this.http = http;
9453
10181
  _this.eventDispatcherService = eventDispatcherService;
9454
10182
  _this.environment = environment;
10183
+ _this.toastService = toastService;
9455
10184
  _this.sseService = sseService;
9456
10185
  _this.modelClass = Message;
9457
10186
  _this.url = 'messages';
9458
10187
  _this.isHydra = true;
9459
- _this.listenEvents();
10188
+ _this.listenMessages();
9460
10189
  return _this;
9461
10190
  }
9462
- /**
9463
- * SSE and Event Dispatcher Services listeners
9464
- */
9465
- MessageService.prototype.listenEvents = function () {
9466
- this.listenMessages();
9467
- };
9468
10191
  /**
9469
10192
  * subscribe to new chat messages
9470
10193
  */
@@ -9487,7 +10210,7 @@
9487
10210
  };
9488
10211
  return MessageService;
9489
10212
  }(RestService));
9490
- MessageService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MessageService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: SseService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10213
+ MessageService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MessageService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: SseService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
9491
10214
  MessageService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MessageService, providedIn: 'root' });
9492
10215
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MessageService, decorators: [{
9493
10216
  type: i0.Injectable,
@@ -9498,7 +10221,7 @@
9498
10221
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9499
10222
  type: i0.Inject,
9500
10223
  args: ['environment']
9501
- }] }, { type: SseService }];
10224
+ }] }, { type: ToastService }, { type: SseService }];
9502
10225
  } });
9503
10226
 
9504
10227
  // @TODO improve base rest service and extend it
@@ -9718,15 +10441,11 @@
9718
10441
 
9719
10442
  var ClientMovementService = /** @class */ (function (_super) {
9720
10443
  __extends(ClientMovementService, _super);
9721
- function ClientMovementService(http, eventDispatcherService, environment) {
9722
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
9723
- _this.http = http;
9724
- _this.eventDispatcherService = eventDispatcherService;
9725
- _this.environment = environment;
10444
+ function ClientMovementService() {
10445
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9726
10446
  _this.modelClass = ClientMovement;
9727
10447
  _this.url = 'client-movements';
9728
10448
  _this.isHydra = true;
9729
- _this.listenEvents();
9730
10449
  return _this;
9731
10450
  }
9732
10451
  /**
@@ -9797,19 +10516,14 @@
9797
10516
  };
9798
10517
  return ClientMovementService;
9799
10518
  }(RestService));
9800
- ClientMovementService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ClientMovementService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10519
+ ClientMovementService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ClientMovementService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
9801
10520
  ClientMovementService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ClientMovementService, providedIn: 'root' });
9802
10521
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ClientMovementService, decorators: [{
9803
10522
  type: i0.Injectable,
9804
10523
  args: [{
9805
10524
  providedIn: 'root'
9806
10525
  }]
9807
- }], ctorParameters: function () {
9808
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
9809
- type: i0.Inject,
9810
- args: ['environment']
9811
- }] }];
9812
- } });
10526
+ }] });
9813
10527
 
9814
10528
  // @Todo refactor with BaseRest service
9815
10529
  /**
@@ -9907,14 +10621,10 @@
9907
10621
 
9908
10622
  var DepreciationService = /** @class */ (function (_super) {
9909
10623
  __extends(DepreciationService, _super);
9910
- function DepreciationService(http, eventDispatcherService, environment) {
9911
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
9912
- _this.http = http;
9913
- _this.eventDispatcherService = eventDispatcherService;
9914
- _this.environment = environment;
10624
+ function DepreciationService() {
10625
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
9915
10626
  _this.modelClass = Depreciation;
9916
10627
  _this.url = 'depreciations';
9917
- _this.listenEvents();
9918
10628
  return _this;
9919
10629
  }
9920
10630
  /**
@@ -9948,14 +10658,6 @@
9948
10658
  this.listenToVehicleClaim();
9949
10659
  this.listenToUpdatedBankAccount();
9950
10660
  };
9951
- /**
9952
- * Get depreciations related to Vehicle category
9953
- */
9954
- DepreciationService.prototype.getVehicleDepreciations = function () {
9955
- return this.get().pipe(operators.map(function (depreciations) {
9956
- return depreciations.filter(function (depreciation) { return depreciation.isVehicleDepreciation(); });
9957
- }));
9958
- };
9959
10661
  DepreciationService.prototype.getOpenBalance = function (depreciation) {
9960
10662
  return this.http.post(this.environment.apiV2 + "/" + this.url + "/opening-balance?financialYear=" + new FinancialYear().year, depreciation)
9961
10663
  .pipe(operators.map(function (response) {
@@ -10037,30 +10739,22 @@
10037
10739
  };
10038
10740
  return DepreciationService;
10039
10741
  }(RestService));
10040
- DepreciationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10742
+ DepreciationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10041
10743
  DepreciationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, providedIn: 'root' });
10042
10744
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, decorators: [{
10043
10745
  type: i0.Injectable,
10044
10746
  args: [{
10045
10747
  providedIn: 'root'
10046
10748
  }]
10047
- }], ctorParameters: function () {
10048
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10049
- type: i0.Inject,
10050
- args: ['environment']
10051
- }] }];
10052
- } });
10749
+ }] });
10053
10750
 
10054
10751
  /**
10055
10752
  * Service to handle document-folders and depending documents logic
10056
10753
  */
10057
10754
  var DocumentFolderService = /** @class */ (function (_super) {
10058
10755
  __extends(DocumentFolderService, _super);
10059
- function DocumentFolderService(http, eventDispatcherService, environment) {
10060
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10061
- _this.http = http;
10062
- _this.eventDispatcherService = eventDispatcherService;
10063
- _this.environment = environment;
10756
+ function DocumentFolderService() {
10757
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10064
10758
  _this.url = 'folders';
10065
10759
  _this.modelClass = DocumentFolder;
10066
10760
  return _this;
@@ -10119,19 +10813,14 @@
10119
10813
  };
10120
10814
  return DocumentFolderService;
10121
10815
  }(RestService));
10122
- DocumentFolderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10816
+ DocumentFolderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10123
10817
  DocumentFolderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, providedIn: 'root' });
10124
10818
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DocumentFolderService, decorators: [{
10125
10819
  type: i0.Injectable,
10126
10820
  args: [{
10127
10821
  providedIn: 'root'
10128
10822
  }]
10129
- }], ctorParameters: function () {
10130
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10131
- type: i0.Inject,
10132
- args: ['environment']
10133
- }] }];
10134
- } });
10823
+ }] });
10135
10824
 
10136
10825
  var EmployeeService = /** @class */ (function (_super) {
10137
10826
  __extends(EmployeeService, _super);
@@ -10266,178 +10955,69 @@
10266
10955
  }));
10267
10956
  };
10268
10957
  FirmService.prototype.getByType = function (type) {
10269
- return this.getAll().pipe(operators.map(function (firms) {
10270
- return firms.filter(function (firm) { return firm.type === type; });
10271
- }));
10272
- };
10273
- FirmService.prototype.updatePhoto = function (firm, photo) {
10274
- var _this = this;
10275
- return this.http.post(this.environment.apiV2 + "/firms/photo?_method=PUT", photo)
10276
- .pipe(operators.map(function (firmPhoto) {
10277
- _this.firm = classTransformer.plainToClass(Firm, Object.assign(firm, { photo: firmPhoto }));
10278
- _this.firmSubject.next(_this.firm);
10279
- return firm;
10280
- }));
10281
- };
10282
- return FirmService;
10283
- }());
10284
- FirmService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FirmService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10285
- FirmService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FirmService, providedIn: 'root' });
10286
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FirmService, decorators: [{
10287
- type: i0.Injectable,
10288
- args: [{
10289
- providedIn: 'root'
10290
- }]
10291
- }], ctorParameters: function () {
10292
- return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
10293
- type: i0.Inject,
10294
- args: ['environment']
10295
- }] }];
10296
- } });
10297
-
10298
- var HeaderTitleService = /** @class */ (function () {
10299
- function HeaderTitleService(router, activatedRoute) {
10300
- this.router = router;
10301
- this.activatedRoute = activatedRoute;
10302
- }
10303
- HeaderTitleService.prototype.handleTitle = function () {
10304
- var _this = this;
10305
- return this.router.events.pipe(operators.filter(function (event) { return event instanceof i1$1.NavigationEnd; }), operators.map(function () { return _this.activatedRoute; }), operators.map(function (route) {
10306
- while (route.firstChild) {
10307
- route = route.firstChild;
10308
- }
10309
- return route;
10310
- }), operators.filter(function (route) { return route.outlet === 'primary'; }), operators.mergeMap(function (route) { return route.data; }));
10311
- };
10312
- return HeaderTitleService;
10313
- }());
10314
- HeaderTitleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: HeaderTitleService, deps: [{ token: i1__namespace$1.Router }, { token: i1__namespace$1.ActivatedRoute }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10315
- HeaderTitleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: HeaderTitleService, providedIn: 'root' });
10316
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: HeaderTitleService, decorators: [{
10317
- type: i0.Injectable,
10318
- args: [{
10319
- providedIn: 'root'
10320
- }]
10321
- }], ctorParameters: function () { return [{ type: i1__namespace$1.Router }, { type: i1__namespace$1.ActivatedRoute }]; } });
10322
-
10323
- /**
10324
- * Service to work with income sources
10325
- */
10326
- var IncomeSourceService = /** @class */ (function (_super) {
10327
- __extends(IncomeSourceService, _super);
10328
- function IncomeSourceService(http, eventDispatcherService, environment) {
10329
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10330
- _this.http = http;
10331
- _this.eventDispatcherService = eventDispatcherService;
10332
- _this.environment = environment;
10333
- _this.url = 'income-sources';
10334
- _this.modelClass = IncomeSource;
10335
- _this.incomeSourceTypeSubject = new rxjs.ReplaySubject(1);
10336
- return _this;
10337
- }
10338
- /**
10339
- * Get income sources tax calculation
10340
- * @param salaryForecast for which tax should be calculated
10341
- */
10342
- IncomeSourceService.prototype.getTaxCalculation = function (salaryForecast) {
10343
- return this.http.post(this.environment.apiV2 + "/" + this.url + "/tax-calculation", salaryForecast)
10344
- .pipe(operators.map(function (response) {
10345
- return classTransformer.plainToClass(SalaryForecast, response);
10346
- }));
10347
- };
10348
- /**
10349
- * Add batch of income sources
10350
- * @param incomeSources to add
10351
- */
10352
- IncomeSourceService.prototype.addBatch = function (incomeSources) {
10353
- var _this = this;
10354
- return this.http.post(this.environment.apiV2 + "/" + this.url, incomeSources)
10355
- .pipe(operators.map(function (addedIncomeSources) {
10356
- var _a;
10357
- // assign respond income sources to provided income sources
10358
- var assignedIncomeSources = addedIncomeSources
10359
- .map(function (incomeSource, index) { return Object.assign(classTransformer.plainToClass(IncomeSource, {}), incomeSource, incomeSources[index]); });
10360
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.INCOME_SOURCES_CREATED, assignedIncomeSources));
10361
- (_a = _this.cache).push.apply(_a, __spreadArray([], __read(assignedIncomeSources)));
10362
- _this.updateCache();
10363
- return assignedIncomeSources;
10364
- }));
10365
- };
10366
- /**
10367
- * Update batch of income sources
10368
- */
10369
- IncomeSourceService.prototype.updateBatch = function (incomeSources, queryParams) {
10370
- var _this = this;
10371
- if (queryParams === void 0) { queryParams = {}; }
10372
- return this.http.put(this.environment.apiV2 + "/" + this.url, incomeSources, queryParams)
10373
- .pipe(operators.map(function (updatedItems) {
10374
- var updatedInstances = updatedItems.map(function (item) { return _this.createModelInstance(_this.modelClass, item); });
10375
- updatedInstances.forEach(function (instance) {
10376
- replace(_this.cache, instance);
10377
- });
10378
- if (incomeSources[0].forecasts.length) {
10379
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.INCOME_SOURCES_UPDATED, incomeSources));
10380
- }
10381
- _this.updateCache();
10382
- return updatedInstances;
10383
- }));
10384
- };
10385
- /**
10386
- * Get income sources by provided types
10387
- * @param types
10388
- */
10389
- IncomeSourceService.prototype.getByTypes = function (types) {
10390
- return this.get()
10391
- .pipe(operators.map(function (incomeSources) { return incomeSources
10392
- .filter(function (incomeSource) { return types.includes(incomeSource.type); }); }));
10958
+ return this.getAll().pipe(operators.map(function (firms) {
10959
+ return firms.filter(function (firm) { return firm.type === type; });
10960
+ }));
10393
10961
  };
10394
- /**
10395
- * Get other incomes types
10396
- */
10397
- IncomeSourceService.prototype.getIncomeSourceTypes = function () {
10962
+ FirmService.prototype.updatePhoto = function (firm, photo) {
10398
10963
  var _this = this;
10399
- if (!this.incomeSourceTypes) {
10400
- this.incomeSourceTypes = [];
10401
- this.http.get(this.environment.apiV2 + "/income-source-types")
10402
- .pipe(operators.map(function (response) {
10403
- return response.map(function (item) { return classTransformer.plainToClass(IncomeSourceType, item); });
10404
- }))
10405
- .subscribe(function (otherIncomesTypes) {
10406
- _this.incomeSourceTypes = otherIncomesTypes;
10407
- _this.incomeSourceTypeSubject.next(_this.incomeSourceTypes);
10408
- });
10409
- }
10410
- return this.incomeSourceTypeSubject.asObservable();
10964
+ return this.http.post(this.environment.apiV2 + "/firms/photo?_method=PUT", photo)
10965
+ .pipe(operators.map(function (firmPhoto) {
10966
+ _this.firm = classTransformer.plainToClass(Firm, Object.assign(firm, { photo: firmPhoto }));
10967
+ _this.firmSubject.next(_this.firm);
10968
+ return firm;
10969
+ }));
10411
10970
  };
10412
- return IncomeSourceService;
10413
- }(RestService));
10414
- IncomeSourceService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10415
- IncomeSourceService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceService, providedIn: 'root' });
10416
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceService, decorators: [{
10971
+ return FirmService;
10972
+ }());
10973
+ FirmService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FirmService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10974
+ FirmService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FirmService, providedIn: 'root' });
10975
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FirmService, decorators: [{
10417
10976
  type: i0.Injectable,
10418
10977
  args: [{
10419
10978
  providedIn: 'root'
10420
10979
  }]
10421
10980
  }], ctorParameters: function () {
10422
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10981
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
10423
10982
  type: i0.Inject,
10424
10983
  args: ['environment']
10425
10984
  }] }];
10426
10985
  } });
10427
10986
 
10987
+ var HeaderTitleService = /** @class */ (function () {
10988
+ function HeaderTitleService(router, activatedRoute) {
10989
+ this.router = router;
10990
+ this.activatedRoute = activatedRoute;
10991
+ }
10992
+ HeaderTitleService.prototype.handleTitle = function () {
10993
+ var _this = this;
10994
+ return this.router.events.pipe(operators.filter(function (event) { return event instanceof i1$1.NavigationEnd; }), operators.map(function () { return _this.activatedRoute; }), operators.map(function (route) {
10995
+ while (route.firstChild) {
10996
+ route = route.firstChild;
10997
+ }
10998
+ return route;
10999
+ }), operators.filter(function (route) { return route.outlet === 'primary'; }), operators.mergeMap(function (route) { return route.data; }));
11000
+ };
11001
+ return HeaderTitleService;
11002
+ }());
11003
+ HeaderTitleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: HeaderTitleService, deps: [{ token: i1__namespace$1.Router }, { token: i1__namespace$1.ActivatedRoute }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11004
+ HeaderTitleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: HeaderTitleService, providedIn: 'root' });
11005
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: HeaderTitleService, decorators: [{
11006
+ type: i0.Injectable,
11007
+ args: [{
11008
+ providedIn: 'root'
11009
+ }]
11010
+ }], ctorParameters: function () { return [{ type: i1__namespace$1.Router }, { type: i1__namespace$1.ActivatedRoute }]; } });
11011
+
10428
11012
  /**
10429
11013
  * Service to work with Other Income Forecasts
10430
11014
  */
10431
11015
  var IncomeSourceForecastService = /** @class */ (function (_super) {
10432
11016
  __extends(IncomeSourceForecastService, _super);
10433
- function IncomeSourceForecastService(http, eventDispatcherService, environment) {
10434
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10435
- _this.http = http;
10436
- _this.eventDispatcherService = eventDispatcherService;
10437
- _this.environment = environment;
11017
+ function IncomeSourceForecastService() {
11018
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10438
11019
  _this.modelClass = IncomeSourceForecast;
10439
11020
  _this.url = 'income-source-forecasts';
10440
- _this.listenEvents();
10441
11021
  return _this;
10442
11022
  }
10443
11023
  /**
@@ -10497,33 +11077,24 @@
10497
11077
  };
10498
11078
  return IncomeSourceForecastService;
10499
11079
  }(RestService));
10500
- IncomeSourceForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceForecastService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11080
+ IncomeSourceForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceForecastService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10501
11081
  IncomeSourceForecastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceForecastService, providedIn: 'root' });
10502
11082
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: IncomeSourceForecastService, decorators: [{
10503
11083
  type: i0.Injectable,
10504
11084
  args: [{
10505
11085
  providedIn: 'root'
10506
11086
  }]
10507
- }], ctorParameters: function () {
10508
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10509
- type: i0.Inject,
10510
- args: ['environment']
10511
- }] }];
10512
- } });
11087
+ }] });
10513
11088
 
10514
11089
  /**
10515
11090
  * Service to work with Salary Forecasts
10516
11091
  */
10517
11092
  var SalaryForecastService = /** @class */ (function (_super) {
10518
11093
  __extends(SalaryForecastService, _super);
10519
- function SalaryForecastService(http, eventDispatcherService, environment) {
10520
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10521
- _this.http = http;
10522
- _this.eventDispatcherService = eventDispatcherService;
10523
- _this.environment = environment;
11094
+ function SalaryForecastService() {
11095
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10524
11096
  _this.modelClass = SalaryForecast;
10525
11097
  _this.url = 'salary-forecasts';
10526
- _this.listenEvents();
10527
11098
  return _this;
10528
11099
  }
10529
11100
  /**
@@ -10583,30 +11154,21 @@
10583
11154
  };
10584
11155
  return SalaryForecastService;
10585
11156
  }(RestService));
10586
- SalaryForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SalaryForecastService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11157
+ SalaryForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SalaryForecastService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10587
11158
  SalaryForecastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SalaryForecastService, providedIn: 'root' });
10588
11159
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SalaryForecastService, decorators: [{
10589
11160
  type: i0.Injectable,
10590
11161
  args: [{
10591
11162
  providedIn: 'root'
10592
11163
  }]
10593
- }], ctorParameters: function () {
10594
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10595
- type: i0.Inject,
10596
- args: ['environment']
10597
- }] }];
10598
- } });
11164
+ }] });
10599
11165
 
10600
11166
  var SoleForecastService = /** @class */ (function (_super) {
10601
11167
  __extends(SoleForecastService, _super);
10602
- function SoleForecastService(http, eventDispatcherService, environment) {
10603
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10604
- _this.http = http;
10605
- _this.eventDispatcherService = eventDispatcherService;
10606
- _this.environment = environment;
11168
+ function SoleForecastService() {
11169
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10607
11170
  _this.modelClass = SoleForecast;
10608
11171
  _this.url = 'sole-forecasts';
10609
- _this.listenEvents();
10610
11172
  return _this;
10611
11173
  }
10612
11174
  /**
@@ -10666,19 +11228,14 @@
10666
11228
  };
10667
11229
  return SoleForecastService;
10668
11230
  }(RestService));
10669
- SoleForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11231
+ SoleForecastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10670
11232
  SoleForecastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, providedIn: 'root' });
10671
11233
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleForecastService, decorators: [{
10672
11234
  type: i0.Injectable,
10673
11235
  args: [{
10674
11236
  providedIn: 'root'
10675
11237
  }]
10676
- }], ctorParameters: function () {
10677
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10678
- type: i0.Inject,
10679
- args: ['environment']
10680
- }] }];
10681
- } });
11238
+ }] });
10682
11239
 
10683
11240
  /**
10684
11241
  * Service to work with intercom
@@ -10755,14 +11312,10 @@
10755
11312
  */
10756
11313
  var LoanService = /** @class */ (function (_super) {
10757
11314
  __extends(LoanService, _super);
10758
- function LoanService(http, eventDispatcherService, environment) {
10759
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
10760
- _this.http = http;
10761
- _this.eventDispatcherService = eventDispatcherService;
10762
- _this.environment = environment;
11315
+ function LoanService() {
11316
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
10763
11317
  _this.url = 'bank-accounts/loans';
10764
11318
  _this.modelClass = Loan;
10765
- _this.listenEvents();
10766
11319
  return _this;
10767
11320
  }
10768
11321
  /**
@@ -10880,43 +11433,33 @@
10880
11433
  };
10881
11434
  return LoanService;
10882
11435
  }(RestService));
10883
- LoanService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LoanService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11436
+ LoanService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LoanService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
10884
11437
  LoanService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LoanService, providedIn: 'root' });
10885
11438
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LoanService, decorators: [{
10886
11439
  type: i0.Injectable,
10887
11440
  args: [{
10888
11441
  providedIn: 'root'
10889
11442
  }]
10890
- }], ctorParameters: function () {
10891
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10892
- type: i0.Inject,
10893
- args: ['environment']
10894
- }] }];
10895
- } });
11443
+ }] });
10896
11444
 
10897
11445
  /**
10898
11446
  * Service to handle service notifications logic
10899
11447
  */
10900
11448
  var ServiceNotificationService = /** @class */ (function (_super) {
10901
11449
  __extends(ServiceNotificationService, _super);
10902
- function ServiceNotificationService(http, eventDispatcherService, environment, sseService) {
10903
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
11450
+ function ServiceNotificationService(http, eventDispatcherService, environment, toastService, sseService) {
11451
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
10904
11452
  _this.http = http;
10905
11453
  _this.eventDispatcherService = eventDispatcherService;
10906
11454
  _this.environment = environment;
11455
+ _this.toastService = toastService;
10907
11456
  _this.sseService = sseService;
10908
11457
  _this.modelClass = Notification;
10909
11458
  _this.url = 'service-notifications';
10910
11459
  _this.isHydra = true;
10911
- _this.listenEvents();
11460
+ _this.listenNotifications();
10912
11461
  return _this;
10913
11462
  }
10914
- /**
10915
- * SSE and Event Dispatcher Services listeners
10916
- */
10917
- ServiceNotificationService.prototype.listenEvents = function () {
10918
- this.listenNotifications();
10919
- };
10920
11463
  /**
10921
11464
  * subscribe to new chat messages
10922
11465
  */
@@ -10939,7 +11482,7 @@
10939
11482
  };
10940
11483
  return ServiceNotificationService;
10941
11484
  }(RestService));
10942
- ServiceNotificationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServiceNotificationService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: SseService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11485
+ ServiceNotificationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServiceNotificationService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: SseService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
10943
11486
  ServiceNotificationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServiceNotificationService, providedIn: 'root' });
10944
11487
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServiceNotificationService, decorators: [{
10945
11488
  type: i0.Injectable,
@@ -10950,7 +11493,7 @@
10950
11493
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
10951
11494
  type: i0.Inject,
10952
11495
  args: ['environment']
10953
- }] }, { type: SseService }];
11496
+ }] }, { type: ToastService }, { type: SseService }];
10954
11497
  } });
10955
11498
 
10956
11499
  /**
@@ -10972,7 +11515,7 @@
10972
11515
  src: '/assets/img/icons/logo.png',
10973
11516
  width: 30,
10974
11517
  height: 7,
10975
- positionX: 168,
11518
+ positionX: 42,
10976
11519
  positionY: 6
10977
11520
  },
10978
11521
  // coords for file section title (group, table, e.t.c.)
@@ -11003,45 +11546,73 @@
11003
11546
  function PdfService() {
11004
11547
  }
11005
11548
  /**
11006
- * Export file form provided HTML tables
11549
+ * Export file from provided HTML tables
11550
+ */
11551
+ PdfService.prototype.exportTables = function (tables, title, fileName, orientation) {
11552
+ var document = this.generateFromTables(orientation, tables, title);
11553
+ document.save(fileName + ".pdf");
11554
+ };
11555
+ /**
11556
+ * Export file from provided array-like table data
11007
11557
  */
11008
- PdfService.prototype.exportTables = function (tables, title, fileName) {
11009
- var document = this.generateFromTables(tables, title);
11558
+ PdfService.prototype.exportFromDataTables = function (dataTables, title, fileName) {
11559
+ var document = this.generateFromDataTables(title, dataTables);
11010
11560
  document.save(fileName + ".pdf");
11011
11561
  };
11012
- PdfService.prototype.generateFromTables = function (tables, title) {
11562
+ /**
11563
+ * Generate file from array-like table data
11564
+ */
11565
+ PdfService.prototype.generateFromDataTables = function (title, dataTables) {
11566
+ var _this = this;
11013
11567
  var pdf = new jsPDF__default["default"]();
11014
11568
  this.setDocumentTitle(pdf, title);
11015
11569
  this.setDocumentLogo(pdf);
11570
+ dataTables.forEach(function (dataTable) {
11571
+ autoTable__default["default"](pdf, Object.assign({ head: [dataTable.header], body: dataTable.rows, foot: [dataTable.footer] }, _this.setTableOptions(pdf, dataTable.caption)));
11572
+ });
11573
+ return pdf;
11574
+ };
11575
+ PdfService.prototype.generateFromTables = function (orientation, tables, title) {
11576
+ var _this = this;
11577
+ var pdf = new jsPDF__default["default"](orientation);
11578
+ this.setDocumentTitle(pdf, title);
11579
+ this.setDocumentLogo(pdf);
11016
11580
  tables.forEach(function (table) {
11017
- var _a;
11018
11581
  // Add table caption if not provided
11019
11582
  if (!table.caption) {
11020
11583
  table.createCaption();
11021
11584
  table.caption.innerText = '';
11022
11585
  }
11023
- // coords of last table
11024
- var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
11025
- pdf.text(table.caption.innerText, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
11026
- // get caption height based on caption content height
11027
- var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize((_a = table.caption) === null || _a === void 0 ? void 0 : _a.innerText, pdf.internal.pageSize.width)).h;
11028
- // table options
11029
- var options = {
11030
- html: table,
11031
- startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
11032
- headStyles: PDF_CONFIG.table.headStyles,
11033
- footStyles: PDF_CONFIG.table.footStyles,
11034
- didParseCell: function (data) {
11035
- // Align last column content to right
11036
- if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
11037
- data.cell.styles.halign = 'right';
11038
- }
11039
- }
11040
- };
11041
- autoTable__default["default"](pdf, options);
11586
+ autoTable__default["default"](pdf, Object.assign({ html: table }, _this.setTableOptions(pdf, table.caption.innerText)));
11042
11587
  });
11043
11588
  return pdf;
11044
11589
  };
11590
+ /**
11591
+ * Set basic options for PDF table
11592
+ */
11593
+ PdfService.prototype.setTableOptions = function (pdf, tableCaption) {
11594
+ if (tableCaption === void 0) { tableCaption = ''; }
11595
+ var lastTableCoords = pdf['lastAutoTable'].finalY || PDF_CONFIG.contentCoords.marginTop;
11596
+ // get caption height based on caption content height
11597
+ var captionHeight = pdf.getTextDimensions(pdf.splitTextToSize(tableCaption, pdf.internal.pageSize.width)).h;
11598
+ pdf.text(tableCaption, PDF_CONFIG.contentCoords.marginLeft, lastTableCoords + PDF_CONFIG.contentCoords.marginTop);
11599
+ return {
11600
+ headStyles: {
11601
+ fillColor: PDF_CONFIG.text.colorPrimary,
11602
+ },
11603
+ footStyles: {
11604
+ fillColor: PDF_CONFIG.text.colorWhite,
11605
+ textColor: PDF_CONFIG.text.colorBlack
11606
+ },
11607
+ startY: lastTableCoords + captionHeight + PDF_CONFIG.contentTitleCoords.marginTop,
11608
+ didParseCell: function (data) {
11609
+ // Align last column content to right
11610
+ if (data.table.columns.length > 1 && (data.column.index === data.table.columns.length - 1)) {
11611
+ data.cell.styles.halign = 'right';
11612
+ }
11613
+ }
11614
+ };
11615
+ };
11045
11616
  PdfService.prototype.setDocumentTitle = function (doc, title) {
11046
11617
  doc.setFontSize(PDF_CONFIG.text.fontSize)
11047
11618
  .setFont(PDF_CONFIG.text.fontName, PDF_CONFIG.text.fontStyle, PDF_CONFIG.text.fontWeight)
@@ -11050,7 +11621,7 @@
11050
11621
  PdfService.prototype.setDocumentLogo = function (doc) {
11051
11622
  var logo = new Image();
11052
11623
  logo.src = PDF_CONFIG.logo.src;
11053
- doc.addImage(logo, 'PNG', PDF_CONFIG.logo.positionX, PDF_CONFIG.logo.positionY, PDF_CONFIG.logo.width, PDF_CONFIG.logo.height);
11624
+ doc.addImage(logo, 'PNG', doc.internal.pageSize.width - PDF_CONFIG.logo.positionX, PDF_CONFIG.logo.positionY, PDF_CONFIG.logo.width, PDF_CONFIG.logo.height);
11054
11625
  };
11055
11626
  return PdfService;
11056
11627
  }());
@@ -11061,133 +11632,7 @@
11061
11632
  args: [{
11062
11633
  providedIn: 'root'
11063
11634
  }]
11064
- }] });
11065
-
11066
- /**
11067
- * Service for work with Property
11068
- */
11069
- var PropertyService = /** @class */ (function (_super) {
11070
- __extends(PropertyService, _super);
11071
- function PropertyService(http, eventDispatcherService, environment) {
11072
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
11073
- _this.http = http;
11074
- _this.eventDispatcherService = eventDispatcherService;
11075
- _this.environment = environment;
11076
- _this.modelClass = Property;
11077
- _this.url = 'properties';
11078
- _this.listenEvents();
11079
- return _this;
11080
- }
11081
- PropertyService.prototype.listenEvents = function () {
11082
- this.listenShareInviteAccepted();
11083
- this.listenServiceSubscriptionUpdated();
11084
- // @TODO Alex: consider to refactor property movements logic similar to client-movements
11085
- this.listenMovementsChanged();
11086
- };
11087
- /**
11088
- * Update cache when share invitation accepted
11089
- */
11090
- PropertyService.prototype.listenShareInviteAccepted = function () {
11091
- var _this = this;
11092
- this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_SHARE_UPDATED).subscribe(function () { return _this.resetCache(); });
11093
- };
11094
- /**
11095
- * Update cache when user's service subscription is updated
11096
- */
11097
- PropertyService.prototype.listenServiceSubscriptionUpdated = function () {
11098
- var _this = this;
11099
- this.eventDispatcherService.on(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED).subscribe(function () { return _this.resetCache(); });
11100
- };
11101
- /**
11102
- * Update cache when property category changed
11103
- */
11104
- PropertyService.prototype.listenMovementsChanged = function () {
11105
- var _this = this;
11106
- // @TODO change dispatcher logic to work with multiple events
11107
- this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_CREATED).subscribe(function () { return _this.resetCache(); });
11108
- this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_UPDATED).subscribe(function () { return _this.resetCache(); });
11109
- this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_MOVEMENT_DELETED).subscribe(function () { return _this.resetCache(); });
11110
- };
11111
- PropertyService.prototype.update = function (property) {
11112
- var _this = this;
11113
- return _super.prototype.update.call(this, property).pipe(operators.map(function (updatedProperty) {
11114
- if (property.documentFile) {
11115
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_UPDATED_WITH_DOCUMENT, property));
11116
- }
11117
- return updatedProperty;
11118
- }));
11119
- };
11120
- PropertyService.prototype.getByCategoryId = function (id) {
11121
- return this.get().pipe(operators.map(function (properties) {
11122
- return properties.filter(function (property) { return property.category.id === id; });
11123
- }));
11124
- };
11125
- /**
11126
- * Activate deactivated property
11127
- */
11128
- PropertyService.prototype.activate = function (property) {
11129
- var _this = this;
11130
- return this.http.post(this.environment.apiV2 + "/property-subscriptions", { user: property.user, property: property })
11131
- .pipe(operators.map(function (propertySubscriptionBase) {
11132
- var newPropertySubscription = classTransformer.plainToClass(PropertySubscription, propertySubscriptionBase);
11133
- var activatedProperty = classTransformer.plainToClass(Property, Object.assign({}, property, { subscriptions: [newPropertySubscription] }));
11134
- replace(_this.cache, activatedProperty);
11135
- _this.updateCache();
11136
- }));
11137
- };
11138
- /**
11139
- * Deactivate activated property
11140
- */
11141
- PropertyService.prototype.deactivate = function (property) {
11142
- var _this = this;
11143
- return this.http.delete(this.environment.apiV2 + "/property-subscriptions/" + property.getCurrentSubscription().id)
11144
- .pipe(operators.map(function () {
11145
- var deactivatedProperty = classTransformer.plainToClass(Property, Object.assign({}, property, { subscriptions: [] }));
11146
- replace(_this.cache, deactivatedProperty);
11147
- _this.updateCache();
11148
- }));
11149
- };
11150
- /**
11151
- * Update property photo
11152
- * @param property Property instance for photo update
11153
- * @param photoFormData FormData with property photo image
11154
- */
11155
- PropertyService.prototype.updatePhoto = function (property, photoFormData) {
11156
- var _this = this;
11157
- return this.http.post(this.environment.apiV2 + "/properties/" + property.id + "/photo?_method=PUT", photoFormData)
11158
- .pipe(operators.map(function (photoLink) {
11159
- property.photo = photoLink;
11160
- // update properties cache
11161
- replace(_this.cache, property);
11162
- _this.updateCache();
11163
- }));
11164
- };
11165
- PropertyService.prototype.getByShareId = function (id) {
11166
- return this.get().pipe(operators.map(function (properties) {
11167
- return properties.filter(function (property) { return property.user.id === id; });
11168
- }));
11169
- };
11170
- /**
11171
- * Get list of active user's properties
11172
- */
11173
- PropertyService.prototype.getActive = function () {
11174
- return this.get().pipe(operators.map(function (properties) { return properties.filter(function (property) { return property.isActive; }); }));
11175
- };
11176
- return PropertyService;
11177
- }(RestService));
11178
- PropertyService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11179
- PropertyService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyService, providedIn: 'root' });
11180
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyService, decorators: [{
11181
- type: i0.Injectable,
11182
- args: [{
11183
- providedIn: 'root'
11184
- }]
11185
- }], ctorParameters: function () {
11186
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11187
- type: i0.Inject,
11188
- args: ['environment']
11189
- }] }];
11190
- } });
11635
+ }] });
11191
11636
 
11192
11637
  function enumToList(data) {
11193
11638
  var list = [];
@@ -11209,74 +11654,17 @@
11209
11654
  MessagesEnum["CREATED_MESSAGE"] = "Transaction(s) created";
11210
11655
  })(MessagesEnum || (MessagesEnum = {}));
11211
11656
 
11212
- /**
11213
- * popup notifications service (toast, snackbar).
11214
- */
11215
- var ToastService = /** @class */ (function () {
11216
- function ToastService() {
11217
- this.toast$ = new rxjs.ReplaySubject(1);
11218
- }
11219
- ToastService.prototype.get = function () {
11220
- return this.toast$.asObservable();
11221
- };
11222
- ToastService.prototype.add = function (toast) {
11223
- this.toast$.next(toast);
11224
- };
11225
- ToastService.prototype.success = function (message) {
11226
- this.add(classTransformer.plainToClass(Toast, {
11227
- type: exports.ToastTypeEnum.SUCCESS,
11228
- title: 'Success!',
11229
- message: message,
11230
- }));
11231
- };
11232
- ToastService.prototype.warning = function (message) {
11233
- this.add(classTransformer.plainToClass(Toast, {
11234
- type: exports.ToastTypeEnum.WARNING,
11235
- title: 'Warning!',
11236
- message: message,
11237
- }));
11238
- };
11239
- ToastService.prototype.error = function (message) {
11240
- this.add(classTransformer.plainToClass(Toast, {
11241
- type: exports.ToastTypeEnum.ERROR,
11242
- title: 'Error!',
11243
- message: message,
11244
- }));
11245
- };
11246
- ToastService.prototype.info = function (message) {
11247
- this.add(classTransformer.plainToClass(Toast, {
11248
- type: exports.ToastTypeEnum.INFO,
11249
- title: 'Information',
11250
- message: message,
11251
- }));
11252
- };
11253
- return ToastService;
11254
- }());
11255
- ToastService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11256
- ToastService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, providedIn: 'root' });
11257
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ToastService, decorators: [{
11258
- type: i0.Injectable,
11259
- args: [{
11260
- providedIn: 'root'
11261
- }]
11262
- }] });
11263
-
11264
11657
  /**
11265
11658
  * Service for transactions business logic
11266
11659
  */
11267
11660
  var TransactionService = /** @class */ (function (_super) {
11268
11661
  __extends(TransactionService, _super);
11269
- function TransactionService(http, eventDispatcherService, environment, toastService) {
11270
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
11271
- _this.http = http;
11272
- _this.eventDispatcherService = eventDispatcherService;
11273
- _this.environment = environment;
11274
- _this.toastService = toastService;
11662
+ function TransactionService() {
11663
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11275
11664
  // url part for Transaction API
11276
11665
  _this.url = 'transactions';
11277
11666
  _this.modelClass = Transaction;
11278
11667
  _this.transactionDeleted = new i0.EventEmitter();
11279
- _this.listenEvents();
11280
11668
  return _this;
11281
11669
  }
11282
11670
  /**
@@ -11347,6 +11735,15 @@
11347
11735
  return transactions.filter(function (transaction) { return transaction.isWorkTank(); });
11348
11736
  }));
11349
11737
  };
11738
+ /**
11739
+ * Get list of property holding costs (transactions related to vacant land property)
11740
+ */
11741
+ TransactionService.prototype.getPropertyHoldingCosts = function (propertyId) {
11742
+ return this.http.get(this.environment.apiV2 + "/" + this.url + "?propertyId=" + propertyId + "&propertyCategoryId=" + exports.PropertyCategoryListEnum.VACANT_LAND)
11743
+ .pipe(operators.map(function (transactionsBase) {
11744
+ return transactionsBase.map(function (transactionBase) { return classTransformer.plainToClass(Transaction, transactionBase); });
11745
+ }));
11746
+ };
11350
11747
  /**
11351
11748
  * get list of taxable transactions with tank type 'Work'
11352
11749
  */
@@ -11543,14 +11940,6 @@
11543
11940
  return null;
11544
11941
  }
11545
11942
  };
11546
- /**
11547
- * Get transactions related to Vehicle category
11548
- */
11549
- TransactionService.prototype.getVehicleTransactions = function () {
11550
- return this.get().pipe(operators.map(function (transactions) {
11551
- return transactions.filter(function (transaction) { return transaction.isVehicleTransaction(); });
11552
- }));
11553
- };
11554
11943
  /**
11555
11944
  * Listen to EventDispatcherService event related to Depreciation changing
11556
11945
  */
@@ -11573,19 +11962,14 @@
11573
11962
  };
11574
11963
  return TransactionService;
11575
11964
  }(RestService));
11576
- 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 });
11965
+ TransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11577
11966
  TransactionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, providedIn: 'root' });
11578
11967
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, decorators: [{
11579
11968
  type: i0.Injectable,
11580
11969
  args: [{
11581
11970
  providedIn: 'root'
11582
11971
  }]
11583
- }], ctorParameters: function () {
11584
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11585
- type: i0.Inject,
11586
- args: ['environment']
11587
- }] }, { type: ToastService }];
11588
- } });
11972
+ }] });
11589
11973
 
11590
11974
  /**
11591
11975
  * Service to handle Property transactions report items data (get income / expense report items, e.t.c.)
@@ -11776,6 +12160,54 @@
11776
12160
  }]
11777
12161
  }] });
11778
12162
 
12163
+ /**
12164
+ * Service to work with holding costs (transactions related to vacant land property)
12165
+ */
12166
+ var PropertyHoldingCostsService = /** @class */ (function () {
12167
+ function PropertyHoldingCostsService(pdfService, currencyPipe, datePipe) {
12168
+ this.pdfService = pdfService;
12169
+ this.currencyPipe = currencyPipe;
12170
+ this.datePipe = datePipe;
12171
+ this.url = 'transactions';
12172
+ this.modelClass = Transaction;
12173
+ }
12174
+ PropertyHoldingCostsService.prototype.initDataTable = function (holdingCosts) {
12175
+ return classTransformer.plainToClass(ExportDataTable, {
12176
+ header: ['Date', 'Description', 'Debit', 'Credit'],
12177
+ rows: this.getDataTableRows(holdingCosts),
12178
+ footer: [
12179
+ 'Total',
12180
+ '',
12181
+ this.currencyPipe.transform(holdingCosts.sumBy('debit')).toString(),
12182
+ this.currencyPipe.transform(holdingCosts.sumBy('credit')).toString(),
12183
+ ]
12184
+ });
12185
+ };
12186
+ /**
12187
+ * Get data for the exporting table rows
12188
+ */
12189
+ PropertyHoldingCostsService.prototype.getDataTableRows = function (holdingCosts) {
12190
+ var _this = this;
12191
+ return holdingCosts.items.map(function (transaction) {
12192
+ return [
12193
+ _this.datePipe.transform(transaction.date, 'dd/MM/YYYY').toString(),
12194
+ transaction.description,
12195
+ _this.currencyPipe.transform(transaction.debit).toString(),
12196
+ _this.currencyPipe.transform(transaction.credit).toString()
12197
+ ];
12198
+ });
12199
+ };
12200
+ return PropertyHoldingCostsService;
12201
+ }());
12202
+ PropertyHoldingCostsService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyHoldingCostsService, deps: [{ token: PdfService }, { token: i2__namespace.CurrencyPipe }, { token: i2__namespace.DatePipe }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12203
+ PropertyHoldingCostsService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyHoldingCostsService, providedIn: 'root' });
12204
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyHoldingCostsService, decorators: [{
12205
+ type: i0.Injectable,
12206
+ args: [{
12207
+ providedIn: 'root'
12208
+ }]
12209
+ }], ctorParameters: function () { return [{ type: PdfService }, { type: i2__namespace.CurrencyPipe }, { type: i2__namespace.DatePipe }]; } });
12210
+
11779
12211
  /**
11780
12212
  * Service for work with Property Categories
11781
12213
  */
@@ -11803,14 +12235,10 @@
11803
12235
  */
11804
12236
  var PropertyDocumentService = /** @class */ (function (_super) {
11805
12237
  __extends(PropertyDocumentService, _super);
11806
- function PropertyDocumentService(http, eventDispatcherService, environment) {
11807
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
11808
- _this.http = http;
11809
- _this.eventDispatcherService = eventDispatcherService;
11810
- _this.environment = environment;
12238
+ function PropertyDocumentService() {
12239
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11811
12240
  _this.modelClass = PropertyDocument;
11812
12241
  _this.url = 'properties/documents';
11813
- _this.listenEvents();
11814
12242
  return _this;
11815
12243
  }
11816
12244
  /**
@@ -11852,32 +12280,23 @@
11852
12280
  };
11853
12281
  return PropertyDocumentService;
11854
12282
  }(RestService));
11855
- PropertyDocumentService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12283
+ PropertyDocumentService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11856
12284
  PropertyDocumentService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, providedIn: 'root' });
11857
12285
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyDocumentService, decorators: [{
11858
12286
  type: i0.Injectable,
11859
12287
  args: [{
11860
12288
  providedIn: 'root'
11861
12289
  }]
11862
- }], ctorParameters: function () {
11863
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11864
- type: i0.Inject,
11865
- args: ['environment']
11866
- }] }];
11867
- } });
12290
+ }] });
11868
12291
 
11869
12292
  // @TODO check and improve logic during refactoring
11870
12293
  var PropertyShareService = /** @class */ (function (_super) {
11871
12294
  __extends(PropertyShareService, _super);
11872
- function PropertyShareService(http, eventDispatcherService, environment) {
11873
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
11874
- _this.http = http;
11875
- _this.eventDispatcherService = eventDispatcherService;
11876
- _this.environment = environment;
12295
+ function PropertyShareService() {
12296
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11877
12297
  // api url parameter for properties shares
11878
12298
  _this.url = 'properties/shares';
11879
12299
  _this.modelClass = PropertyShare;
11880
- _this.listenEvents();
11881
12300
  return _this;
11882
12301
  }
11883
12302
  /**
@@ -11964,19 +12383,14 @@
11964
12383
  };
11965
12384
  return PropertyShareService;
11966
12385
  }(RestService));
11967
- PropertyShareService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12386
+ PropertyShareService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11968
12387
  PropertyShareService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, providedIn: 'root' });
11969
12388
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: PropertyShareService, decorators: [{
11970
12389
  type: i0.Injectable,
11971
12390
  args: [{
11972
12391
  providedIn: 'root'
11973
12392
  }]
11974
- }], ctorParameters: function () {
11975
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11976
- type: i0.Inject,
11977
- args: ['environment']
11978
- }] }];
11979
- } });
12393
+ }] });
11980
12394
 
11981
12395
  var PropertySaleService = /** @class */ (function (_super) {
11982
12396
  __extends(PropertySaleService, _super);
@@ -12094,11 +12508,8 @@
12094
12508
  this.serviceSubscriptionsSubject = new rxjs.ReplaySubject(1);
12095
12509
  this.servicePaymentsSubject = new rxjs.ReplaySubject(1);
12096
12510
  this.subscriptionChangeSubject = new rxjs.BehaviorSubject(null);
12097
- this.listenEvents();
12098
- }
12099
- SubscriptionService.prototype.listenEvents = function () {
12100
12511
  this.listenSubscriptions();
12101
- };
12512
+ }
12102
12513
  SubscriptionService.prototype.getSubscription = function (force) {
12103
12514
  var _this = this;
12104
12515
  if (force === void 0) { force = false; }
@@ -12243,14 +12654,10 @@
12243
12654
  */
12244
12655
  var TaxReviewService = /** @class */ (function (_super) {
12245
12656
  __extends(TaxReviewService, _super);
12246
- function TaxReviewService(http, eventDispatcherService, environment) {
12247
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
12248
- _this.http = http;
12249
- _this.eventDispatcherService = eventDispatcherService;
12250
- _this.environment = environment;
12657
+ function TaxReviewService() {
12658
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
12251
12659
  _this.url = 'tax-reviews';
12252
12660
  _this.modelClass = TaxReview;
12253
- _this.listenEvents();
12254
12661
  return _this;
12255
12662
  }
12256
12663
  /**
@@ -12324,200 +12731,110 @@
12324
12731
  };
12325
12732
  return TaxReviewService;
12326
12733
  }(RestService));
12327
- TaxReviewService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12734
+ TaxReviewService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
12328
12735
  TaxReviewService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, providedIn: 'root' });
12329
12736
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewService, decorators: [{
12330
12737
  type: i0.Injectable,
12331
12738
  args: [{
12332
12739
  providedIn: 'root'
12333
12740
  }]
12334
- }], ctorParameters: function () {
12335
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12336
- type: i0.Inject,
12337
- args: ['environment']
12338
- }] }];
12339
- } });
12741
+ }] });
12340
12742
 
12341
12743
  /**
12342
12744
  * Service to work with tax review history
12343
12745
  */
12344
12746
  var TaxReviewHistoryService = /** @class */ (function (_super) {
12345
12747
  __extends(TaxReviewHistoryService, _super);
12346
- function TaxReviewHistoryService(http, eventDispatcherService, environment) {
12347
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
12348
- _this.http = http;
12349
- _this.eventDispatcherService = eventDispatcherService;
12350
- _this.environment = environment;
12748
+ function TaxReviewHistoryService() {
12749
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
12351
12750
  _this.url = 'tax-reviews/history';
12352
12751
  _this.modelClass = TaxReview;
12353
- // subscribe on tax review updating
12354
- eventDispatcherService.on(exports.AppEventTypeEnum.TAX_REVIEW_UPDATED).subscribe(function (taxReview) {
12355
- var tempCache = ___default["default"].cloneDeep(_this.cache);
12356
- // insert element at the beginning of the array
12357
- tempCache.unshift(taxReview);
12358
- _this.cache = tempCache;
12359
- _this.updateCache();
12360
- });
12361
12752
  return _this;
12362
12753
  }
12363
- return TaxReviewHistoryService;
12364
- }(RestService));
12365
- TaxReviewHistoryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12366
- TaxReviewHistoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, providedIn: 'root' });
12367
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, decorators: [{
12368
- type: i0.Injectable,
12369
- args: [{
12370
- providedIn: 'root'
12371
- }]
12372
- }], ctorParameters: function () {
12373
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12374
- type: i0.Inject,
12375
- args: ['environment']
12376
- }] }];
12377
- } });
12378
-
12379
- /**
12380
- * Service to work with tax summary logic
12381
- */
12382
- var TaxSummaryService = /** @class */ (function () {
12383
- function TaxSummaryService(http, eventDispatcherService, environment) {
12384
- this.http = http;
12385
- this.eventDispatcherService = eventDispatcherService;
12386
- this.environment = environment;
12387
- this.taxSummaryActualsSubject = new rxjs.ReplaySubject(1);
12388
- this.taxSummaryForecastsSubject = new rxjs.ReplaySubject(1);
12389
- this.listenEvents();
12390
- }
12391
- TaxSummaryService.prototype.listenEvents = function () {
12392
- this.listenToIncomeSourceForecastsEvents();
12393
- };
12394
- /**
12395
- * Get actual tax summary items
12396
- */
12397
- TaxSummaryService.prototype.getActuals = function () {
12398
- var _this = this;
12399
- this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.ACTUALS, {})
12400
- .subscribe(function (response) {
12401
- var taxSummary = classTransformer.plainToClass(TaxSummary, response);
12402
- _this.taxSummaryActualsSubject.next(taxSummary);
12403
- return taxSummary;
12404
- });
12405
- return this.taxSummaryActualsSubject.asObservable();
12406
- };
12407
- /**
12408
- * Get forecast tax summary items
12409
- */
12410
- TaxSummaryService.prototype.getForecast = function () {
12411
- var _this = this;
12412
- this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.FORECASTS, {})
12413
- .subscribe(function (response) {
12414
- var taxSummary = classTransformer.plainToClass(TaxSummary, response);
12415
- _this.taxSummaryForecastsSubject.next(taxSummary);
12416
- return taxSummary;
12417
- });
12418
- return this.taxSummaryForecastsSubject.asObservable();
12754
+ TaxReviewHistoryService.prototype.listenEvents = function () {
12755
+ this.listenTaxReviewUpdate();
12419
12756
  };
12420
12757
  /**
12421
- * Listen to EventDispatcherService events related to Income source forecasts
12758
+ * Update tax review history cache when single tax review updated.
12422
12759
  */
12423
- TaxSummaryService.prototype.listenToIncomeSourceForecastsEvents = function () {
12760
+ TaxReviewHistoryService.prototype.listenTaxReviewUpdate = function () {
12424
12761
  var _this = this;
12425
- this.eventDispatcherService
12426
- .on([exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED])
12427
- .subscribe(function () {
12428
- _this.getForecast().subscribe();
12762
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.TAX_REVIEW_UPDATED).subscribe(function (taxReview) {
12763
+ var tempCache = ___default["default"].cloneDeep(_this.cache);
12764
+ // insert element at the beginning of the array
12765
+ tempCache.unshift(taxReview);
12766
+ _this.cache = tempCache;
12767
+ _this.updateCache();
12429
12768
  });
12430
12769
  };
12431
- return TaxSummaryService;
12432
- }());
12433
- TaxSummaryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12434
- TaxSummaryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, providedIn: 'root' });
12435
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, decorators: [{
12436
- type: i0.Injectable,
12437
- args: [{
12438
- providedIn: 'root'
12439
- }]
12440
- }], ctorParameters: function () {
12441
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12442
- type: i0.Inject,
12443
- args: ['environment']
12444
- }] }];
12445
- } });
12446
-
12447
- // @TODO Don't look at the commented code. Will be refactored/removed during TT-1503
12448
- /**
12449
- * Service for transaction allocations business logic
12450
- * @TODO alex refactor
12451
- */
12452
- var TransactionAllocationService = /** @class */ (function (_super) {
12453
- __extends(TransactionAllocationService, _super);
12454
- function TransactionAllocationService(http, eventDispatcherService, environment) {
12455
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
12456
- _this.http = http;
12457
- _this.eventDispatcherService = eventDispatcherService;
12458
- _this.environment = environment;
12459
- // API URL param for transaction allocations
12460
- _this.url = 'transactions-allocations';
12461
- _this.modelClass = TransactionAllocation;
12462
- _this.listenEvents();
12463
- return _this;
12464
- }
12465
- /**
12466
- * Add single transaction allocation
12467
- */
12468
- TransactionAllocationService.prototype.add = function (allocation) {
12469
- return this.addBatch([allocation]).pipe(operators.map(function (newAllocations) { return newAllocations[0]; }));
12470
- };
12471
- /**
12472
- * get list of transactions allocations related with passed bank transactions list
12473
- */
12474
- TransactionAllocationService.prototype.getByTransactions = function (transactions) {
12475
- var ids = transactions.map(function (transaction) { return transaction.id; });
12476
- return this.get()
12477
- .pipe(operators.map(function (transactionAllocations) {
12478
- return transactionAllocations.filter(function (allocation) { return ids.includes(allocation.transaction.id); });
12479
- }));
12480
- };
12481
- TransactionAllocationService.prototype.listenEvents = function () {
12482
- this.onTransactionsCreated();
12483
- this.onDepreciationCreated();
12484
- this.onTransactionDeleted();
12770
+ return TaxReviewHistoryService;
12771
+ }(RestService));
12772
+ TaxReviewHistoryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
12773
+ TaxReviewHistoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, providedIn: 'root' });
12774
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxReviewHistoryService, decorators: [{
12775
+ type: i0.Injectable,
12776
+ args: [{
12777
+ providedIn: 'root'
12778
+ }]
12779
+ }] });
12780
+
12781
+ /**
12782
+ * Service to work with tax summary logic
12783
+ */
12784
+ var TaxSummaryService = /** @class */ (function () {
12785
+ function TaxSummaryService(http, eventDispatcherService, environment) {
12786
+ this.http = http;
12787
+ this.eventDispatcherService = eventDispatcherService;
12788
+ this.environment = environment;
12789
+ this.taxSummaryActualsSubject = new rxjs.ReplaySubject(1);
12790
+ this.taxSummaryForecastsSubject = new rxjs.ReplaySubject(1);
12791
+ this.listenEvents();
12792
+ }
12793
+ TaxSummaryService.prototype.listenEvents = function () {
12794
+ this.listenToIncomeSourceForecastsEvents();
12485
12795
  };
12486
12796
  /**
12487
- * Reset cache on transactions created
12797
+ * Get actual tax summary items
12488
12798
  */
12489
- TransactionAllocationService.prototype.onTransactionsCreated = function () {
12799
+ TaxSummaryService.prototype.getActuals = function () {
12490
12800
  var _this = this;
12491
- this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTIONS_CREATED).subscribe(function () {
12492
- // Update allocations cache to synchronize data and fire subscriptions
12493
- _this.resetCache();
12801
+ this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.ACTUALS, {})
12802
+ .subscribe(function (response) {
12803
+ var taxSummary = classTransformer.plainToClass(TaxSummary, response);
12804
+ _this.taxSummaryActualsSubject.next(taxSummary);
12805
+ return taxSummary;
12494
12806
  });
12807
+ return this.taxSummaryActualsSubject.asObservable();
12495
12808
  };
12496
12809
  /**
12497
- * Reset cache on depreciation created
12810
+ * Get forecast tax summary items
12498
12811
  */
12499
- TransactionAllocationService.prototype.onDepreciationCreated = function () {
12812
+ TaxSummaryService.prototype.getForecast = function () {
12500
12813
  var _this = this;
12501
- this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATIONS_CREATED).subscribe(function () {
12502
- // Update allocations cache to synchronize data and fire subscriptions
12503
- _this.resetCache();
12814
+ this.http.get(this.environment.apiV2 + "/tax-summary/" + exports.TaxSummaryTypeEnum.FORECASTS, {})
12815
+ .subscribe(function (response) {
12816
+ var taxSummary = classTransformer.plainToClass(TaxSummary, response);
12817
+ _this.taxSummaryForecastsSubject.next(taxSummary);
12818
+ return taxSummary;
12504
12819
  });
12820
+ return this.taxSummaryForecastsSubject.asObservable();
12505
12821
  };
12506
12822
  /**
12507
- * Reset cache on transaction deleted
12823
+ * Listen to EventDispatcherService events related to Income source forecasts
12508
12824
  */
12509
- TransactionAllocationService.prototype.onTransactionDeleted = function () {
12825
+ TaxSummaryService.prototype.listenToIncomeSourceForecastsEvents = function () {
12510
12826
  var _this = this;
12511
- this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_DELETED).subscribe(function () {
12512
- // Update allocations cache to synchronize data and fire subscriptions
12513
- _this.resetCache();
12827
+ this.eventDispatcherService
12828
+ .on([exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_CREATED, exports.AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED])
12829
+ .subscribe(function () {
12830
+ _this.getForecast().subscribe();
12514
12831
  });
12515
12832
  };
12516
- return TransactionAllocationService;
12517
- }(RestService));
12518
- TransactionAllocationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionAllocationService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12519
- TransactionAllocationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionAllocationService, providedIn: 'root' });
12520
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionAllocationService, decorators: [{
12833
+ return TaxSummaryService;
12834
+ }());
12835
+ TaxSummaryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12836
+ TaxSummaryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, providedIn: 'root' });
12837
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TaxSummaryService, decorators: [{
12521
12838
  type: i0.Injectable,
12522
12839
  args: [{
12523
12840
  providedIn: 'root'
@@ -12742,11 +13059,8 @@
12742
13059
 
12743
13060
  var UserEventSettingService = /** @class */ (function (_super) {
12744
13061
  __extends(UserEventSettingService, _super);
12745
- function UserEventSettingService(http, eventDispatcherService, environment) {
12746
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
12747
- _this.http = http;
12748
- _this.eventDispatcherService = eventDispatcherService;
12749
- _this.environment = environment;
13062
+ function UserEventSettingService() {
13063
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
12750
13064
  _this.modelClass = UserEventSetting;
12751
13065
  _this.url = 'user-event-settings';
12752
13066
  _this.isHydra = true;
@@ -12781,27 +13095,19 @@
12781
13095
  };
12782
13096
  return UserEventSettingService;
12783
13097
  }(RestService));
12784
- UserEventSettingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13098
+ UserEventSettingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
12785
13099
  UserEventSettingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, providedIn: 'root' });
12786
13100
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, decorators: [{
12787
13101
  type: i0.Injectable,
12788
13102
  args: [{
12789
13103
  providedIn: 'root'
12790
13104
  }]
12791
- }], ctorParameters: function () {
12792
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12793
- type: i0.Inject,
12794
- args: ['environment']
12795
- }] }];
12796
- } });
13105
+ }] });
12797
13106
 
12798
13107
  var UserEventTypeService = /** @class */ (function (_super) {
12799
13108
  __extends(UserEventTypeService, _super);
12800
- function UserEventTypeService(http, eventDispatcherService, environment) {
12801
- var _this = _super.call(this, http, eventDispatcherService, environment) || this;
12802
- _this.http = http;
12803
- _this.eventDispatcherService = eventDispatcherService;
12804
- _this.environment = environment;
13109
+ function UserEventTypeService() {
13110
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
12805
13111
  _this.modelClass = UserEventType;
12806
13112
  _this.url = 'user-event-types';
12807
13113
  _this.isHydra = true;
@@ -12809,252 +13115,138 @@
12809
13115
  }
12810
13116
  return UserEventTypeService;
12811
13117
  }(RestService));
12812
- UserEventTypeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13118
+ UserEventTypeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
12813
13119
  UserEventTypeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, providedIn: 'root' });
12814
13120
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, decorators: [{
12815
13121
  type: i0.Injectable,
12816
13122
  args: [{
12817
13123
  providedIn: 'root'
12818
13124
  }]
12819
- }], ctorParameters: function () {
12820
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12821
- type: i0.Inject,
12822
- args: ['environment']
12823
- }] }];
12824
- } });
13125
+ }] });
12825
13126
 
12826
13127
  /**
12827
13128
  * Service that allows to work with WorkTank operations
12828
- * @TODO separate into multiple services, extend restService
13129
+ * @TODO separate vehicles and logbooks to different api
12829
13130
  */
12830
- var VehicleService = /** @class */ (function () {
12831
- function VehicleService(http, transactionService, depreciationService, chartAccountsService, eventDispatcherService, environment) {
12832
- this.http = http;
12833
- this.transactionService = transactionService;
12834
- this.depreciationService = depreciationService;
12835
- this.chartAccountsService = chartAccountsService;
12836
- this.eventDispatcherService = eventDispatcherService;
12837
- this.environment = environment;
12838
- this.vehiclesSubject = new rxjs.ReplaySubject(1);
12839
- this.vehicleClaimSubject = new rxjs.ReplaySubject(1);
12840
- this.vehicleClaimRateSubject = new rxjs.ReplaySubject(1);
12841
- this.vehicleTaxReturnSubject = new rxjs.ReplaySubject(1);
12842
- this.incomePositionsSubject = new rxjs.ReplaySubject(1);
13131
+ var VehicleService = /** @class */ (function (_super) {
13132
+ __extends(VehicleService, _super);
13133
+ function VehicleService() {
13134
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
13135
+ _this.url = 'vehicles';
13136
+ _this.modelClass = Vehicle;
13137
+ _this.messageCreated = MessagesEnum$1.VEHICLE_CREATED;
13138
+ _this.messageUpdated = MessagesEnum$1.VEHICLE_UPDATED;
13139
+ _this.messageDeleted = MessagesEnum$1.VEHICLE_DELETED;
13140
+ return _this;
12843
13141
  }
12844
- VehicleService.prototype.getVehicles = function () {
12845
- var _this = this;
12846
- // @TODO create backend for get logbook
12847
- if (!this._vehicles) {
12848
- this.http.get(this.environment.apiV2 + "/vehicles")
12849
- .pipe(operators.map(function (response) {
12850
- return response.map(function (item) { return classTransformer.plainToClass(Vehicle, item); });
12851
- }))
12852
- .subscribe(function (vehicles) {
12853
- _this._vehicles = vehicles;
12854
- _this.vehiclesSubject.next(vehicles);
12855
- });
12856
- }
12857
- return this.vehiclesSubject.asObservable();
12858
- };
12859
- /**
12860
- * Get vehicles claim amount
12861
- */
12862
- VehicleService.prototype.getVehiclesClaim = function () {
12863
- var _this = this;
12864
- if (!this._vehicleClaim) {
12865
- this.http.get(this.environment.apiV2 + "/vehicle-claims")
12866
- .pipe(operators.map(function (response) {
12867
- // return Vehicle claim from backend or create new if it not exist
12868
- return response.length ? response.map(function (item) { return classTransformer.plainToClass(VehicleClaim, item); })[0] : classTransformer.plainToClass(VehicleClaim, {});
12869
- }))
12870
- .subscribe(function (vehicleClaim) {
12871
- _this._vehicleClaim = vehicleClaim;
12872
- _this.vehicleClaimSubject.next(vehicleClaim);
12873
- });
12874
- }
12875
- return this.vehicleClaimSubject.asObservable();
12876
- };
12877
- /**
12878
- * Add new vehicle claim
12879
- * @param claim object which should be added
12880
- */
12881
- VehicleService.prototype.addVehicleClaim = function (claim) {
12882
- var _this = this;
12883
- return this.http.post(this.environment.apiV2 + "/vehicle-claims", claim).pipe(operators.map(function (response) {
12884
- _this._vehicleClaim = classTransformer.plainToClass(VehicleClaim, response);
12885
- _this.vehicleClaimSubject.next(_this._vehicleClaim);
12886
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_CLAIM_CREATED, null));
12887
- }));
12888
- };
12889
- /**
12890
- * Get vehicles claim rate for current financial year
12891
- */
12892
- VehicleService.prototype.getVehiclesClaimRate = function () {
12893
- var _this = this;
12894
- if (!this._vehicleClaimRate) {
12895
- this.chartAccountsService.getChartAccountsById(exports.ChartAccountsListEnum.KLMS_TRAVELLED_FOR_WORK)
12896
- .pipe(operators.map(function (response) {
12897
- return response.values.find(function (chartAccount) { return chartAccount.financialYear === new FinancialYear().year; }).value;
12898
- }))
12899
- .subscribe(function (claimRate) {
12900
- _this._vehicleClaimRate = claimRate;
12901
- _this.vehicleClaimRateSubject.next(_this._vehicleClaimRate);
12902
- });
12903
- }
12904
- return this.vehicleClaimRateSubject.asObservable();
12905
- };
12906
- /**
12907
- * Get vehicles tax return for vehicle transactions & depreciations
12908
- */
12909
- VehicleService.prototype.getVehiclesTaxReturn = function () {
12910
- var _this = this;
12911
- if (!this._vehicleTaxReturn) {
12912
- rxjs.combineLatest([
12913
- // @Todo refactor to avoid injection of another services
12914
- this.transactionService.get(),
12915
- this.depreciationService.get(),
12916
- this.getVehiclesClaim()
12917
- ]).pipe(operators.map(function (_b) {
12918
- var _c = __read(_b, 3), transactions = _c[0], depreciations = _c[1], vehicleClaim = _c[2];
12919
- var chartAccountsHeadingsIds = enumToList(exports.ChartAccountsHeadingVehicleListEnum)
12920
- .map(function (item) { return item.value; });
12921
- // get transactions & depreciations which chart accounts headings are belong to vehicle category
12922
- // but except KLMS transaction
12923
- var filteredItems = __spreadArray(__spreadArray([], __read(transactions)), __read(depreciations)).filter(function (item) {
12924
- var _a;
12925
- return chartAccountsHeadingsIds.includes((_a = item.chartAccounts.heading) === null || _a === void 0 ? void 0 : _a.id) && !item.chartAccounts.isKlmsForWork();
12926
- });
12927
- // get claim amount sum
12928
- return filteredItems.reduce(function (sum, item) {
12929
- // @Todo remove item.amount negative sign when depreciations will be refactored and will have negative sign
12930
- return sum + ((item instanceof Depreciation ? item.currentYearForecast.amount : -item.amount) * (vehicleClaim.workUsage / 100));
12931
- }, 0);
12932
- }))
12933
- .subscribe(function (taxReturn) {
12934
- _this._vehicleTaxReturn = taxReturn;
12935
- _this.vehicleTaxReturnSubject.next(_this._vehicleTaxReturn);
12936
- });
12937
- }
12938
- return this.vehicleTaxReturnSubject.asObservable();
12939
- };
12940
- /**
12941
- * Update vehicle claim
12942
- * @param claim which should be updated
12943
- *
12944
- * @TODO alex refresh depreciation/transaction cache
12945
- */
12946
- VehicleService.prototype.updateVehicleClaim = function (claim) {
12947
- var _this = this;
12948
- return this.http.put(this.environment.apiV2 + "/vehicle-claims/" + claim.id, claim).pipe(operators.map(function (response) {
12949
- var updatedVehicleClaim = classTransformer.plainToClass(VehicleClaim, response);
12950
- _this._vehicleClaim = updatedVehicleClaim;
12951
- _this.vehicleClaimSubject.next(_this._vehicleClaim);
12952
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_CLAIM_UPDATED, null));
12953
- return updatedVehicleClaim;
12954
- }));
13142
+ VehicleService.prototype.listenEvents = function () {
13143
+ this.listenLogbookAdded();
13144
+ this.listenLogbookUpdated();
13145
+ this.listenLogbookDeleted();
12955
13146
  };
12956
13147
  /**
12957
- * Add new logbook for desired vehicle
12958
- * @param logbook which should be added
12959
- * @param vehicle for which logbook object should be added
13148
+ * Add a new logbook items to the vehicle when a new one created
12960
13149
  */
12961
- VehicleService.prototype.addLogbook = function (logbook, vehicle) {
13150
+ VehicleService.prototype.listenLogbookAdded = function () {
12962
13151
  var _this = this;
12963
- return this.http.post(this.environment.apiV2 + "/vehicles/" + vehicle.id + "/logbooks", logbook)
12964
- .pipe(operators.map(function (response) {
12965
- _this._vehicles.find(function (v) { return v.id === vehicle.id; }).logbook.push(response);
12966
- // we update nested logbook object inside vehicles list. So list is not changed and next not emit subscriptions updates.
12967
- // that is why we recreate vehicles array
12968
- _this.vehiclesSubject.next(_this._vehicles.map(function (item) { return classTransformer.plainToClass(Vehicle, item); }));
12969
- }));
13152
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_CREATED)
13153
+ .subscribe(function (result) {
13154
+ var tempCache = cloneDeep__default["default"](_this.cache);
13155
+ tempCache.find(function (vehicle) { return vehicle.id === result.vehicleId; }).logbook.push(result.logbook);
13156
+ _this.cache = tempCache;
13157
+ _this.updateCache();
13158
+ });
12970
13159
  };
12971
13160
  /**
12972
- * Update logbook
12973
- * @param logbook which should be updated
12974
- * @param vehicle for which logbook object should be updated
13161
+ * Replace vehicle's logbook with updated instance when logbook item updated
12975
13162
  */
12976
- VehicleService.prototype.updateLogbook = function (logbook, vehicle) {
13163
+ VehicleService.prototype.listenLogbookUpdated = function () {
12977
13164
  var _this = this;
12978
- return this.http.put(this.environment.apiV2 + "/vehicles/" + vehicle.id + "/logbooks/" + logbook.id, logbook).pipe(operators.map(function (response) {
12979
- var editedVehicle = _this._vehicles.find(function (v) { return v.id === vehicle.id; });
12980
- var editedLogbookIndex = editedVehicle.logbook.findIndex(function (l) { return l.id === logbook.id; });
12981
- editedVehicle.logbook.splice(editedLogbookIndex, 1, classTransformer.plainToClass(VehicleLogbook, response));
12982
- // we update nested logbook object inside vehicles list. So list is not changed and next not emit subscriptions updates.
12983
- // that is why we recreate vehicles array
12984
- _this.vehiclesSubject.next(_this._vehicles.map(function (item) { return classTransformer.plainToClass(Vehicle, item); }));
12985
- }));
13165
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_UPDATED)
13166
+ .subscribe(function (result) {
13167
+ var tempCache = cloneDeep__default["default"](_this.cache);
13168
+ replace(tempCache.find(function (vehicle) { return vehicle.id === result.vehicleId; }).logbook, result.logbook);
13169
+ _this.cache = tempCache;
13170
+ _this.updateCache();
13171
+ });
12986
13172
  };
12987
13173
  /**
12988
- * Delete trip
12989
- * @param logbook for which trip should be deleted
12990
- * @param vehicle for which trip should be deleted
13174
+ * Remove logbook item from vehicle when logbook deleted
12991
13175
  */
12992
- VehicleService.prototype.deleteTrip = function (logbook, vehicle) {
13176
+ VehicleService.prototype.listenLogbookDeleted = function () {
12993
13177
  var _this = this;
12994
- return this.http.delete(this.environment.apiV2 + "/vehicles/" + vehicle.id + "/logbooks/" + logbook.id)
12995
- .pipe(operators.map(function () {
12996
- var editedVehicle = _this._vehicles.find(function (v) { return v.id === vehicle.id; });
12997
- var deletedLogbookIndex = editedVehicle.logbook.findIndex(function (l) { return l.id === logbook.id; });
12998
- editedVehicle.logbook.splice(deletedLogbookIndex, 1);
12999
- // we update nested logbook object inside vehicles list. So list is not changed and next not emit subscriptions updates.
13000
- // that is why we recreate vehicles array
13001
- _this.vehiclesSubject.next(_this._vehicles.map(function (item) { return classTransformer.plainToClass(Vehicle, item); }));
13002
- }));
13178
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_DELETED)
13179
+ .subscribe(function (result) {
13180
+ var tempCache = cloneDeep__default["default"](_this.cache);
13181
+ var vehicle = tempCache.find(function (vehicle) { return vehicle.id === result.vehicleId; });
13182
+ vehicle.logbook = vehicle.logbook.filter(function (logbook) { return logbook.id !== result.logbook.id; });
13183
+ _this.cache = tempCache;
13184
+ _this.updateCache();
13185
+ });
13003
13186
  };
13004
- /**
13005
- * Add new vehicle
13006
- * @param vehicle which should be added
13007
- */
13008
- VehicleService.prototype.addVehicle = function (vehicle) {
13187
+ return VehicleService;
13188
+ }(RestService));
13189
+ VehicleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
13190
+ VehicleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleService, providedIn: 'root' });
13191
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleService, decorators: [{
13192
+ type: i0.Injectable,
13193
+ args: [{
13194
+ providedIn: 'root'
13195
+ }]
13196
+ }] });
13197
+
13198
+ /**
13199
+ * Vehicle logbook service. Allows user to add, update or delete vehicle trips
13200
+ * @TODO extend rest service after it refactored
13201
+ */
13202
+ var VehicleLogbookService = /** @class */ (function () {
13203
+ function VehicleLogbookService(http, eventDispatcherService, environment, toastService) {
13204
+ this.http = http;
13205
+ this.eventDispatcherService = eventDispatcherService;
13206
+ this.environment = environment;
13207
+ this.toastService = toastService;
13208
+ }
13209
+ VehicleLogbookService.prototype.add = function (logbook, vehicleId) {
13009
13210
  var _this = this;
13010
- return this.http.post(this.environment.apiV2 + "/vehicles", { name: vehicle.name })
13011
- .pipe(operators.map(function (response) {
13012
- _this._vehicles.push(classTransformer.plainToClass(Vehicle, response));
13013
- _this.vehiclesSubject.next(_this._vehicles);
13211
+ return this.http.post(this.environment.apiV2 + "/vehicles/" + vehicleId + "/logbooks", logbook)
13212
+ .pipe(operators.map(function (vehicleLogbookBase) {
13213
+ var newVehicleLogbook = classTransformer.plainToClass(VehicleLogbook, vehicleLogbookBase);
13214
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_CREATED, { logbook: newVehicleLogbook, vehicleId: vehicleId }));
13215
+ _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_CREATED);
13216
+ return newVehicleLogbook;
13014
13217
  }));
13015
13218
  };
13016
- /**
13017
- * Update vehicle
13018
- * @param vehicle which should be updated
13019
- */
13020
- VehicleService.prototype.updateVehicle = function (vehicle) {
13219
+ VehicleLogbookService.prototype.update = function (logbook, vehicleId) {
13021
13220
  var _this = this;
13022
- return this.http.put(this.environment.apiV2 + "/vehicles/" + vehicle.id, { name: vehicle.name })
13023
- .pipe(operators.map(function (response) {
13024
- var editedVehicleIndex = _this._vehicles.findIndex(function (v) { return v.id === vehicle.id; });
13025
- _this._vehicles.splice(editedVehicleIndex, 1, classTransformer.plainToClass(Vehicle, response));
13026
- _this.vehiclesSubject.next(_this._vehicles);
13221
+ return this.http.put(this.environment.apiV2 + "/vehicles/" + vehicleId + "/logbooks/" + logbook.id, logbook).pipe(operators.map(function (vehicleLogbookBase) {
13222
+ var updatedVehicleLogbook = classTransformer.plainToClass(VehicleLogbook, vehicleLogbookBase);
13223
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_UPDATED, { logbook: updatedVehicleLogbook, vehicleId: vehicleId }));
13224
+ _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_UPDATED);
13225
+ return classTransformer.plainToClass(VehicleLogbook, updatedVehicleLogbook);
13027
13226
  }));
13028
13227
  };
13029
- /**
13030
- * Delete vehicle
13031
- * @param vehicle which should be deleted
13032
- */
13033
- VehicleService.prototype.deleteVehicle = function (vehicle) {
13228
+ VehicleLogbookService.prototype.delete = function (logbook, vehicleId) {
13034
13229
  var _this = this;
13035
- return this.http.delete(this.environment.apiV2 + "/vehicles/" + vehicle.id)
13230
+ return this.http.delete(this.environment.apiV2 + "/vehicles/" + vehicleId + "/logbooks/" + logbook.id)
13036
13231
  .pipe(operators.map(function () {
13037
- var deletedVehicleIndex = _this._vehicles.findIndex(function (v) { return v.id === vehicle.id; });
13038
- _this._vehicles.splice(deletedVehicleIndex, 1);
13039
- // we update nested logbook object inside vehicles list. So list is not changed and next not emit subscriptions updates.
13040
- // that is why we recreate vehicles array
13041
- _this.vehiclesSubject.next(_this._vehicles.map(function (item) { return classTransformer.plainToClass(Vehicle, item); }));
13232
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_DELETED, { logbook: logbook, vehicleId: vehicleId }));
13233
+ _this.toastService.success(MessagesEnum$1.VEHICLE_LOGBOOK_DELETED);
13042
13234
  }));
13043
13235
  };
13044
- return VehicleService;
13236
+ return VehicleLogbookService;
13045
13237
  }());
13046
- VehicleService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleService, deps: [{ token: i1__namespace.HttpClient }, { token: TransactionService }, { token: DepreciationService }, { token: ChartAccountsService }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13047
- VehicleService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleService, providedIn: 'root' });
13048
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleService, decorators: [{
13238
+ VehicleLogbookService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleLogbookService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13239
+ VehicleLogbookService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleLogbookService, providedIn: 'root' });
13240
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: VehicleLogbookService, decorators: [{
13049
13241
  type: i0.Injectable,
13050
13242
  args: [{
13051
13243
  providedIn: 'root'
13052
13244
  }]
13053
13245
  }], ctorParameters: function () {
13054
- return [{ type: i1__namespace.HttpClient }, { type: TransactionService }, { type: DepreciationService }, { type: ChartAccountsService }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13246
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13055
13247
  type: i0.Inject,
13056
13248
  args: ['environment']
13057
- }] }];
13249
+ }] }, { type: ToastService }];
13058
13250
  } });
13059
13251
 
13060
13252
  /**
@@ -13209,6 +13401,39 @@
13209
13401
  return AbstractForm;
13210
13402
  }(forms.FormGroup));
13211
13403
 
13404
+ /**
13405
+ * Check if at least one form field is true, otherwise form is invalid.
13406
+ * Use with groups of boolean form controls (checkbox, toggle, etc.)
13407
+ */
13408
+ function atLeastOneCheckedValidator() {
13409
+ return function (formGroup) {
13410
+ return Object.values(formGroup.controls)
13411
+ .find(function (control) { return control.value; }) ? null : { nothingChecked: true };
13412
+ };
13413
+ }
13414
+
13415
+ var ClientIncomeTypesForm = /** @class */ (function (_super) {
13416
+ __extends(ClientIncomeTypesForm, _super);
13417
+ function ClientIncomeTypesForm(clientIncomeTypes) {
13418
+ var _this = _super.call(this, {
13419
+ salary: new forms.FormControl(clientIncomeTypes.salary),
13420
+ rental: new forms.FormControl(clientIncomeTypes.rental),
13421
+ soleTrader: new forms.FormControl(clientIncomeTypes.soleTrader),
13422
+ dividends: new forms.FormControl(clientIncomeTypes.dividends),
13423
+ other: new forms.FormControl(clientIncomeTypes.other)
13424
+ }, atLeastOneCheckedValidator()) || this;
13425
+ _this.clientIncomeTypes = clientIncomeTypes;
13426
+ return _this;
13427
+ }
13428
+ ClientIncomeTypesForm.prototype.submit = function () {
13429
+ if (!this.valid) {
13430
+ return null;
13431
+ }
13432
+ return Object.assign({}, this.clientIncomeTypes, this.value);
13433
+ };
13434
+ return ClientIncomeTypesForm;
13435
+ }(AbstractForm));
13436
+
13212
13437
  var LoginForm = /** @class */ (function (_super) {
13213
13438
  __extends(LoginForm, _super);
13214
13439
  function LoginForm() {
@@ -13292,6 +13517,139 @@
13292
13517
  return ResetPasswordForm;
13293
13518
  }(AbstractForm));
13294
13519
 
13520
+ var MAX_NAME_LENGTH = 60;
13521
+ var VehicleForm = /** @class */ (function (_super) {
13522
+ __extends(VehicleForm, _super);
13523
+ function VehicleForm(vehicle) {
13524
+ var _this = _super.call(this, {
13525
+ name: new forms.FormControl(vehicle.name, [forms.Validators.required, forms.Validators.maxLength(MAX_NAME_LENGTH)])
13526
+ }) || this;
13527
+ _this.vehicle = vehicle;
13528
+ return _this;
13529
+ }
13530
+ /**
13531
+ * @TODO save model, add generics and handle it in AbstractForm
13532
+ */
13533
+ VehicleForm.prototype.submit = function () {
13534
+ return classTransformer.plainToClass(VehicleClaim, Object.assign({}, this.vehicle, this.getRawValue()));
13535
+ };
13536
+ return VehicleForm;
13537
+ }(AbstractForm));
13538
+
13539
+ var VehicleClaimForm = /** @class */ (function (_super) {
13540
+ __extends(VehicleClaimForm, _super);
13541
+ function VehicleClaimForm(vehicleClaim, logbooks) {
13542
+ var _this = _super.call(this, {
13543
+ method: new forms.FormControl(vehicleClaim.method, forms.Validators.required),
13544
+ isManual: new forms.FormControl(vehicleClaim.isManual),
13545
+ kilometers: new forms.FormControl({
13546
+ value: vehicleClaim.kilometers,
13547
+ disabled: !vehicleClaim.isManual
13548
+ }),
13549
+ workUsage: new forms.FormControl({
13550
+ value: vehicleClaim.workUsage,
13551
+ disabled: !vehicleClaim.isManual
13552
+ })
13553
+ }) || this;
13554
+ _this.vehicleClaim = vehicleClaim;
13555
+ _this.logbooks = logbooks;
13556
+ _this.setIsManualState();
13557
+ _this.listenMethodChanges();
13558
+ _this.listenIsManualChanges();
13559
+ return _this;
13560
+ }
13561
+ /**
13562
+ * Check if vehicle claim method changed
13563
+ */
13564
+ VehicleClaimForm.prototype.isMethodChanged = function () {
13565
+ return this.vehicleClaim.method !== this.get('method').value;
13566
+ };
13567
+ /**
13568
+ * Check if KLMs method selected
13569
+ */
13570
+ VehicleClaimForm.prototype.isKLMsMethod = function () {
13571
+ return this.get('method').value === exports.VehicleClaimMethodEnum.KMS;
13572
+ };
13573
+ /**
13574
+ * Check if Logbook method selected
13575
+ */
13576
+ VehicleClaimForm.prototype.isLogbookMethod = function () {
13577
+ return this.get('method').value === exports.VehicleClaimMethodEnum.LOGBOOK;
13578
+ };
13579
+ /**
13580
+ * Check if user selected manual calculation
13581
+ */
13582
+ VehicleClaimForm.prototype.isManual = function () {
13583
+ return this.get('isManual').value;
13584
+ };
13585
+ /**
13586
+ * @TODO save model, add generics and handle it in AbstractForm
13587
+ */
13588
+ VehicleClaimForm.prototype.submit = function () {
13589
+ return classTransformer.plainToClass(VehicleClaim, Object.assign({}, this.vehicleClaim, this.getRawValue()));
13590
+ };
13591
+ VehicleClaimForm.prototype.setIsManualState = function () {
13592
+ if (this.logbooks.isBestPeriodExist()) {
13593
+ this.get('isManual').enable();
13594
+ }
13595
+ else {
13596
+ this.get('isManual').disable();
13597
+ this.get('isManual').setValue(true);
13598
+ }
13599
+ };
13600
+ /**
13601
+ * Handle method field value changes.
13602
+ * Set work usage value depended of selected method.
13603
+ */
13604
+ VehicleClaimForm.prototype.listenMethodChanges = function () {
13605
+ var _this = this;
13606
+ this.get('method').valueChanges.subscribe(function (method) {
13607
+ if (method === exports.VehicleClaimMethodEnum.KMS) {
13608
+ _this.get('workUsage').setValue(0);
13609
+ }
13610
+ else if (method === exports.VehicleClaimMethodEnum.LOGBOOK && !_this.isManual()) {
13611
+ _this.get('workUsage').setValue(_this.logbooks.getBestPeriod().workUsage);
13612
+ }
13613
+ _this.setValues();
13614
+ });
13615
+ };
13616
+ /**
13617
+ * Handle isManual field value changes.
13618
+ * Enable/disable fields depended of isManual value
13619
+ */
13620
+ VehicleClaimForm.prototype.listenIsManualChanges = function () {
13621
+ var _this = this;
13622
+ this.get('isManual').valueChanges.subscribe(function (isManual) {
13623
+ if (isManual) {
13624
+ _this.get('kilometers').enable();
13625
+ _this.get('workUsage').enable();
13626
+ }
13627
+ else {
13628
+ _this.get('kilometers').disable();
13629
+ _this.get('workUsage').disable();
13630
+ }
13631
+ _this.setValues();
13632
+ });
13633
+ };
13634
+ /**
13635
+ * Set automatic calculated values depended of current method for non-manual vehicle claim
13636
+ */
13637
+ VehicleClaimForm.prototype.setValues = function () {
13638
+ if (this.isManual()) {
13639
+ return;
13640
+ }
13641
+ switch (this.get('method').value) {
13642
+ case exports.VehicleClaimMethodEnum.LOGBOOK:
13643
+ this.get('workUsage').setValue(this.logbooks.getBestPeriod().workUsage);
13644
+ break;
13645
+ case exports.VehicleClaimMethodEnum.KMS:
13646
+ var businessKms = this.logbooks.getBusinessLogbooks().getKlms();
13647
+ this.get('kilometers').setValue(businessKms < this.vehicleClaim.kmsLimit ? businessKms : this.vehicleClaim.kmsLimit);
13648
+ }
13649
+ };
13650
+ return VehicleClaimForm;
13651
+ }(AbstractForm));
13652
+
13295
13653
  /**
13296
13654
  * Public API Surface of tt-core
13297
13655
  */
@@ -13301,6 +13659,9 @@
13301
13659
  */
13302
13660
 
13303
13661
  exports.AbstractForm = AbstractForm;
13662
+ exports.AccountSetupItem = AccountSetupItem;
13663
+ exports.AccountSetupItemCollection = AccountSetupItemCollection;
13664
+ exports.AccountSetupService = AccountSetupService;
13304
13665
  exports.Address = Address;
13305
13666
  exports.AddressService = AddressService;
13306
13667
  exports.AppEvent = AppEvent;
@@ -13338,12 +13699,16 @@
13338
13699
  exports.ChartAccountsHeading = ChartAccountsHeading;
13339
13700
  exports.ChartAccountsMetadata = ChartAccountsMetadata;
13340
13701
  exports.ChartAccountsService = ChartAccountsService;
13702
+ exports.ChartAccountsValue = ChartAccountsValue;
13341
13703
  exports.ChartData = ChartData;
13342
13704
  exports.ChartSerie = ChartSerie;
13343
13705
  exports.Chat = Chat;
13344
13706
  exports.ChatService = ChatService;
13345
13707
  exports.ClientCollection = ClientCollection;
13346
13708
  exports.ClientDetails = ClientDetails;
13709
+ exports.ClientIncomeTypes = ClientIncomeTypes;
13710
+ exports.ClientIncomeTypesForm = ClientIncomeTypesForm;
13711
+ exports.ClientIncomeTypesService = ClientIncomeTypesService;
13347
13712
  exports.ClientInvite = ClientInvite;
13348
13713
  exports.ClientInviteService = ClientInviteService;
13349
13714
  exports.ClientMovement = ClientMovement;
@@ -13387,6 +13752,7 @@
13387
13752
  exports.Endpoint = Endpoint;
13388
13753
  exports.EquityPositionChartService = EquityPositionChartService;
13389
13754
  exports.EventDispatcherService = EventDispatcherService;
13755
+ exports.ExportDataTable = ExportDataTable;
13390
13756
  exports.FinancialYear = FinancialYear;
13391
13757
  exports.Firm = Firm;
13392
13758
  exports.FirmService = FirmService;
@@ -13408,7 +13774,6 @@
13408
13774
  exports.LoanPayment = LoanPayment;
13409
13775
  exports.LoanPayout = LoanPayout;
13410
13776
  exports.LoanService = LoanService;
13411
- exports.LogbookCollection = LogbookCollection;
13412
13777
  exports.LogbookPeriod = LogbookPeriod;
13413
13778
  exports.LoginForm = LoginForm;
13414
13779
  exports.MODULE_URL_LIST = MODULE_URL_LIST;
@@ -13439,6 +13804,7 @@
13439
13804
  exports.PropertyEquityChartData = PropertyEquityChartData;
13440
13805
  exports.PropertyEquityChartItem = PropertyEquityChartItem;
13441
13806
  exports.PropertyForecast = PropertyForecast;
13807
+ exports.PropertyHoldingCostsService = PropertyHoldingCostsService;
13442
13808
  exports.PropertyReportItem = PropertyReportItem;
13443
13809
  exports.PropertyReportItemCollection = PropertyReportItemCollection;
13444
13810
  exports.PropertyReportItemDepreciationCollection = PropertyReportItemDepreciationCollection;
@@ -13514,7 +13880,13 @@
13514
13880
  exports.UserToRegister = UserToRegister;
13515
13881
  exports.Vehicle = Vehicle;
13516
13882
  exports.VehicleClaim = VehicleClaim;
13883
+ exports.VehicleClaimForm = VehicleClaimForm;
13884
+ exports.VehicleClaimService = VehicleClaimService;
13885
+ exports.VehicleCollection = VehicleCollection;
13886
+ exports.VehicleForm = VehicleForm;
13517
13887
  exports.VehicleLogbook = VehicleLogbook;
13888
+ exports.VehicleLogbookCollection = VehicleLogbookCollection;
13889
+ exports.VehicleLogbookService = VehicleLogbookService;
13518
13890
  exports.VehicleService = VehicleService;
13519
13891
  exports.WORK_TANK_LOGBOOK_PURPOSE_OPTIONS = WORK_TANK_LOGBOOK_PURPOSE_OPTIONS;
13520
13892
  exports.XlsxService = XlsxService;