taxtank-core 0.32.0 → 0.32.1

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 (133) hide show
  1. package/esm2022/lib/collections/subscription/service-subscription.collection.mjs +3 -3
  2. package/esm2022/lib/collections/vehicle/best-vehicle-logbook.collection.mjs +18 -14
  3. package/esm2022/lib/collections/vehicle/vehicle-logbook.collection.mjs +10 -5
  4. package/esm2022/lib/db/Models/firm/client-invite.mjs +3 -3
  5. package/esm2022/lib/db/Models/subscription/service-product.mjs +1 -1
  6. package/esm2022/lib/db/Models/subscription/service-subscription.mjs +1 -1
  7. package/esm2022/lib/services/account-setup/account-setup.service.mjs +2 -2
  8. package/esm2022/lib/services/http/bank/bank-connection/bank-connection.service.mjs +4 -6
  9. package/esm2022/lib/services/http/chat/chat.service.mjs +4 -5
  10. package/esm2022/lib/services/http/chat/message.service.mjs +4 -5
  11. package/esm2022/lib/services/http/firm/client-invite/client-invite-messages.enum.mjs +5 -2
  12. package/esm2022/lib/services/http/firm/client-invite/client-invite.service.mjs +56 -63
  13. package/esm2022/lib/services/http/firm/client-movement/client-movement.service.mjs +32 -32
  14. package/esm2022/lib/services/http/rest/rest.service.mjs +23 -2
  15. package/esm2022/lib/services/http/subscription/service-payment-method/service-payment-method.service.mjs +4 -5
  16. package/esm2022/lib/services/http/subscription/service-subscription/subscription.service.mjs +4 -7
  17. package/fesm2022/taxtank-core.mjs +507 -488
  18. package/fesm2022/taxtank-core.mjs.map +1 -1
  19. package/lib/collections/vehicle/best-vehicle-logbook.collection.d.ts +2 -1
  20. package/lib/collections/vehicle/vehicle-logbook.collection.d.ts +3 -2
  21. package/lib/db/Models/firm/client-invite.d.ts +2 -2
  22. package/lib/db/Models/subscription/service-product.d.ts +2 -1
  23. package/lib/db/Models/subscription/service-subscription.d.ts +2 -0
  24. package/lib/services/http/bank/bank-connection/bank-connection.service.d.ts +1 -3
  25. package/lib/services/http/chat/chat.service.d.ts +2 -3
  26. package/lib/services/http/chat/message.service.d.ts +2 -3
  27. package/lib/services/http/firm/client-invite/client-invite-messages.enum.d.ts +5 -2
  28. package/lib/services/http/firm/client-invite/client-invite.service.d.ts +15 -14
  29. package/lib/services/http/firm/client-movement/client-movement.service.d.ts +19 -13
  30. package/lib/services/http/rest/rest.service.d.ts +13 -1
  31. package/lib/services/http/subscription/service-payment-method/service-payment-method.service.d.ts +2 -3
  32. package/lib/services/http/subscription/service-subscription/subscription.service.d.ts +2 -5
  33. package/package.json +1 -1
  34. package/lib/db/Models/address.d.ts.map +0 -1
  35. package/lib/db/Models/bank/bank-account-balance.d.ts.map +0 -1
  36. package/lib/db/Models/bank/bank-account-property.d.ts.map +0 -1
  37. package/lib/db/Models/bank/bank-account.d.ts.map +0 -1
  38. package/lib/db/Models/bank/bank-connection.d.ts.map +0 -1
  39. package/lib/db/Models/bank/bank-transaction-import.d.ts.map +0 -1
  40. package/lib/db/Models/bank/bank-transaction.d.ts.map +0 -1
  41. package/lib/db/Models/bank/bank.d.ts.map +0 -1
  42. package/lib/db/Models/bank/basiq-job.d.ts.map +0 -1
  43. package/lib/db/Models/chart-accounts/chart-accounts-depreciation.d.ts.map +0 -1
  44. package/lib/db/Models/chart-accounts/chart-accounts-heading.d.ts.map +0 -1
  45. package/lib/db/Models/chart-accounts/chart-accounts-meta-field.d.ts.map +0 -1
  46. package/lib/db/Models/chart-accounts/chart-accounts-value.d.ts.map +0 -1
  47. package/lib/db/Models/chart-accounts/chart-accounts.d.ts.map +0 -1
  48. package/lib/db/Models/client/client-details.d.ts.map +0 -1
  49. package/lib/db/Models/client/client-income-types.d.ts.map +0 -1
  50. package/lib/db/Models/client/occupation.d.ts.map +0 -1
  51. package/lib/db/Models/country.d.ts.map +0 -1
  52. package/lib/db/Models/depreciation/depreciation-capital-project.d.ts.map +0 -1
  53. package/lib/db/Models/depreciation/depreciation-forecast.d.ts.map +0 -1
  54. package/lib/db/Models/depreciation/depreciation.d.ts.map +0 -1
  55. package/lib/db/Models/document/document-base.d.ts.map +0 -1
  56. package/lib/db/Models/document/document-folder.d.ts.map +0 -1
  57. package/lib/db/Models/document/document.d.ts.map +0 -1
  58. package/lib/db/Models/document/property-document.d.ts.map +0 -1
  59. package/lib/db/Models/file.d.ts.map +0 -1
  60. package/lib/db/Models/firm/chat.d.ts.map +0 -1
  61. package/lib/db/Models/firm/client-invite.d.ts.map +0 -1
  62. package/lib/db/Models/firm/client-movement.d.ts.map +0 -1
  63. package/lib/db/Models/firm/employee-invite.d.ts.map +0 -1
  64. package/lib/db/Models/firm/firm-invite.d.ts.map +0 -1
  65. package/lib/db/Models/firm/firm.d.ts.map +0 -1
  66. package/lib/db/Models/firm/message-document.d.ts.map +0 -1
  67. package/lib/db/Models/firm/message.d.ts.map +0 -1
  68. package/lib/db/Models/holding/holding-sale.d.ts.map +0 -1
  69. package/lib/db/Models/incomeSource/income-source-forecast.d.ts.map +0 -1
  70. package/lib/db/Models/incomeSource/income-source-type.d.ts.map +0 -1
  71. package/lib/db/Models/incomeSource/income-source.d.ts.map +0 -1
  72. package/lib/db/Models/incomeSource/salary-forecast.d.ts.map +0 -1
  73. package/lib/db/Models/loan/borrowing-expense-loan.d.ts.map +0 -1
  74. package/lib/db/Models/loan/borrowing-expense.d.ts.map +0 -1
  75. package/lib/db/Models/loan/loan-payout.d.ts.map +0 -1
  76. package/lib/db/Models/loan/loan.d.ts.map +0 -1
  77. package/lib/db/Models/phone.d.ts.map +0 -1
  78. package/lib/db/Models/property/borrowing-report.d.ts.map +0 -1
  79. package/lib/db/Models/property/property-category-movement.d.ts.map +0 -1
  80. package/lib/db/Models/property/property-category.d.ts.map +0 -1
  81. package/lib/db/Models/property/property-forecast.d.ts.map +0 -1
  82. package/lib/db/Models/property/property-sale/property-sale-tax-exemption-meta-field.d.ts.map +0 -1
  83. package/lib/db/Models/property/property-sale/property-sale.d.ts.map +0 -1
  84. package/lib/db/Models/property/property-sale/tax-exemption-meta-field.d.ts.map +0 -1
  85. package/lib/db/Models/property/property-sale/tax-exemption.d.ts.map +0 -1
  86. package/lib/db/Models/property/property-share.d.ts.map +0 -1
  87. package/lib/db/Models/property/property-subscription.d.ts.map +0 -1
  88. package/lib/db/Models/property/property-valuation.d.ts.map +0 -1
  89. package/lib/db/Models/property/property.d.ts.map +0 -1
  90. package/lib/db/Models/service-notification.d.ts.map +0 -1
  91. package/lib/db/Models/sole/bas-report.d.ts.map +0 -1
  92. package/lib/db/Models/sole/sole-business-activity.d.ts.map +0 -1
  93. package/lib/db/Models/sole/sole-business-allocation.d.ts.map +0 -1
  94. package/lib/db/Models/sole/sole-business-loss-offset-rule.d.ts.map +0 -1
  95. package/lib/db/Models/sole/sole-business-loss.d.ts.map +0 -1
  96. package/lib/db/Models/sole/sole-business.d.ts.map +0 -1
  97. package/lib/db/Models/sole/sole-contact.d.ts.map +0 -1
  98. package/lib/db/Models/sole/sole-depreciation-method.d.ts.map +0 -1
  99. package/lib/db/Models/sole/sole-details.d.ts.map +0 -1
  100. package/lib/db/Models/sole/sole-forecast.d.ts.map +0 -1
  101. package/lib/db/Models/sole/sole-invoice-item.d.ts.map +0 -1
  102. package/lib/db/Models/sole/sole-invoice-template.d.ts.map +0 -1
  103. package/lib/db/Models/sole/sole-invoice.d.ts.map +0 -1
  104. package/lib/db/Models/spare/spare-document-category.d.ts.map +0 -1
  105. package/lib/db/Models/spare/spare-document.d.ts.map +0 -1
  106. package/lib/db/Models/subscription/service-payment-method.d.ts.map +0 -1
  107. package/lib/db/Models/subscription/service-payment.d.ts.map +0 -1
  108. package/lib/db/Models/subscription/service-price.d.ts.map +0 -1
  109. package/lib/db/Models/subscription/service-product.d.ts.map +0 -1
  110. package/lib/db/Models/subscription/service-subscription-item.d.ts.map +0 -1
  111. package/lib/db/Models/subscription/service-subscription.d.ts.map +0 -1
  112. package/lib/db/Models/tax-calculation.d.ts.map +0 -1
  113. package/lib/db/Models/tax-return/tax-return-category.d.ts.map +0 -1
  114. package/lib/db/Models/tax-return/tax-return-item.d.ts.map +0 -1
  115. package/lib/db/Models/tax-return/tax-return.d.ts.map +0 -1
  116. package/lib/db/Models/transaction/allocation-rule-condition.d.ts.map +0 -1
  117. package/lib/db/Models/transaction/allocation-rule-transaction-meta-field.d.ts.map +0 -1
  118. package/lib/db/Models/transaction/allocation-rule-transaction.d.ts.map +0 -1
  119. package/lib/db/Models/transaction/allocation-rule.d.ts.map +0 -1
  120. package/lib/db/Models/transaction/transaction-allocation.d.ts.map +0 -1
  121. package/lib/db/Models/transaction/transaction-meta-field.d.ts.map +0 -1
  122. package/lib/db/Models/transaction/transaction.d.ts.map +0 -1
  123. package/lib/db/Models/user/employee-details.d.ts.map +0 -1
  124. package/lib/db/Models/user/registration-invite.d.ts.map +0 -1
  125. package/lib/db/Models/user/user-event-setting.d.ts.map +0 -1
  126. package/lib/db/Models/user/user-event-type-category.d.ts.map +0 -1
  127. package/lib/db/Models/user/user-event-type.d.ts.map +0 -1
  128. package/lib/db/Models/user/user-event.d.ts.map +0 -1
  129. package/lib/db/Models/vehicle/vehicle-claim-details.d.ts.map +0 -1
  130. package/lib/db/Models/vehicle/vehicle-claim.d.ts.map +0 -1
  131. package/lib/db/Models/vehicle/vehicle-logbook.d.ts.map +0 -1
  132. package/lib/db/Models/vehicle/vehicle.d.ts.map +0 -1
  133. package/taxtank-core.d.ts.map +0 -1
@@ -27,10 +27,10 @@ import { Validators, UntypedFormGroup, UntypedFormControl, UntypedFormArray, For
27
27
  import compact from 'lodash/compact';
28
28
  import concat from 'lodash/concat';
29
29
  import cloneDeep$1 from 'lodash/cloneDeep';
30
- import clone from 'lodash/clone';
31
- import * as mixpanel from 'mixpanel-browser';
32
30
  import { EventSourcePolyfill } from 'event-source-polyfill/src/eventsource.min.js';
33
31
  import { JwtHelperService } from '@auth0/angular-jwt';
32
+ import * as mixpanel from 'mixpanel-browser';
33
+ import clone from 'lodash/clone';
34
34
  import * as i4 from '@angular/router';
35
35
  import { NavigationEnd } from '@angular/router';
36
36
  import _ from 'lodash';
@@ -545,7 +545,7 @@ class Ticket extends AbstractModel {
545
545
  let Chat$1 = class Chat extends AbstractModel {
546
546
  };
547
547
 
548
- let ClientInvite$1 = class ClientInvite extends AbstractModel {
548
+ let ClientInvite$1 = class ClientInvite extends ObservableModel {
549
549
  };
550
550
 
551
551
  let ClientMovement$1 = class ClientMovement extends AbstractModel {
@@ -8382,10 +8382,10 @@ class ServiceSubscriptionCollection extends Collection {
8382
8382
  return dictionary;
8383
8383
  }
8384
8384
  findByProduct(product) {
8385
- return this.find((subscription) => !!subscription.items.find((item) => item.price.product.id === product.id));
8385
+ return this.find((subscription) => subscription.roles.includes(product.role));
8386
8386
  }
8387
8387
  filterByProduct(product) {
8388
- return this.filter((subscription) => !!subscription.items.find((item) => item.price.product.id === product.id));
8388
+ return this.filter((subscription) => subscription.roles.includes(product.role));
8389
8389
  }
8390
8390
  hasPropertyTank() {
8391
8391
  return !!this.getItems().propertiesItem;
@@ -8496,8 +8496,8 @@ class VehicleLogbookCollection extends Collection {
8496
8496
  * Get collection of non-personal logbooks (work-related, sole-related).
8497
8497
  * @TODO Vik: Best period: move this and related logic to backend
8498
8498
  */
8499
- getClaimableLogbooks() {
8500
- return this.filterBy('isPersonal', false);
8499
+ getClaimableLogbooks(isSole = false) {
8500
+ return this.filter((logbook) => !logbook.isPersonal && (isSole ? logbook.isSoleTank() : logbook.isWorkTank()));
8501
8501
  }
8502
8502
  /**
8503
8503
  * Calculate total kilometers traveled
@@ -8518,6 +8518,11 @@ class VehicleLogbookCollection extends Collection {
8518
8518
  .reduce((sum, logbook) => sum + logbook.kilometers, 0);
8519
8519
  return round(workKilometers / this.kilometers * 100, 2);
8520
8520
  }
8521
+ getWorkUsageByTank(isSole) {
8522
+ const workKilometers = this.getClaimableLogbooks(isSole).items
8523
+ .reduce((sum, logbook) => sum + logbook.kilometers, 0);
8524
+ return round(workKilometers / this.kilometers * 100, 2);
8525
+ }
8521
8526
  /**
8522
8527
  * Get list of logbooks related to passed vehicle claim
8523
8528
  */
@@ -8531,8 +8536,8 @@ class VehicleLogbookCollection extends Collection {
8531
8536
  /**
8532
8537
  * get collection of logbooks with the biggest work usage for {@link BestVehicleLogbookCollection.periodDuration}
8533
8538
  */
8534
- getBest() {
8535
- return BestVehicleLogbookCollection.fromLogbooks(this);
8539
+ getBest(isSole = false) {
8540
+ return BestVehicleLogbookCollection.fromLogbooks(this, isSole);
8536
8541
  }
8537
8542
  }
8538
8543
 
@@ -8550,8 +8555,9 @@ class BestVehicleLogbookCollection extends VehicleLogbookCollection {
8550
8555
  * constructor is private because we want to prevent collection initialization via 'new' operator.
8551
8556
  * We should create instances only with fromLogbooks method
8552
8557
  */
8553
- constructor(logbooks) {
8558
+ constructor(logbooks, isSole = false) {
8554
8559
  super([]);
8560
+ this.isSole = isSole;
8555
8561
  if (!this.isBestPeriodExist(logbooks)) {
8556
8562
  return;
8557
8563
  }
@@ -8564,11 +8570,14 @@ class BestVehicleLogbookCollection extends VehicleLogbookCollection {
8564
8570
  if (logbooks.length < 2) {
8565
8571
  return false;
8566
8572
  }
8573
+ if (!(logbooks instanceof VehicleLogbookCollection)) {
8574
+ logbooks = new VehicleLogbookCollection(logbooks);
8575
+ }
8567
8576
  return BestVehicleLogbookCollection.periodDuration < (logbooks.last.date.getTime() - logbooks.first.date.getTime());
8568
8577
  }
8569
8578
  getWorkUsageByClaim(claim) {
8570
- const claimKilometers = this.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
8571
- return round(this.workUsage * (claimKilometers / this.kilometers), 2);
8579
+ const claimKilometers = this.getByVehicleClaim(claim).getClaimableLogbooks(this.isSole).kilometers;
8580
+ return round(this.getWorkUsageByTank(this.isSole) * (claimKilometers / this.kilometers), 2);
8572
8581
  }
8573
8582
  /**
8574
8583
  * Set Date Range with the biggest work usage percent
@@ -8584,10 +8593,10 @@ class BestVehicleLogbookCollection extends VehicleLogbookCollection {
8584
8593
  */
8585
8594
  calculateBestPeriod(logbooks) {
8586
8595
  // get a list of date ranges that could potentially be the best
8587
- const periods = this.getPeriods(logbooks.getClaimableLogbooks());
8596
+ const periods = this.getPeriods(logbooks);
8588
8597
  periods.forEach((period) => {
8589
8598
  const logbooksInPeriod = logbooks.filterByRange('date', period.start.toDate(), period.end.toDate());
8590
- if (!this.period || (this.workUsage < logbooksInPeriod.workUsage)) {
8599
+ if (!this.period || (this.getWorkUsageByTank(this.isSole) < logbooksInPeriod.getWorkUsageByTank(this.isSole))) {
8591
8600
  this.period = period;
8592
8601
  this.items = logbooksInPeriod.toArray();
8593
8602
  }
@@ -8595,16 +8604,17 @@ class BestVehicleLogbookCollection extends VehicleLogbookCollection {
8595
8604
  }
8596
8605
  // get list of date ranges for each of passed logbook
8597
8606
  getPeriods(logbooks) {
8607
+ const claimable = logbooks.getClaimableLogbooks(this.isSole);
8598
8608
  // get a list of date ranges that could potentially be the best
8599
- const periods = logbooks
8609
+ const periods = claimable
8600
8610
  // skip logbooks whose range ends after the last logbook
8601
8611
  .filter((logbook) => this.getPeriodByLogbook(logbook).end.toDate() < logbooks.last.date)
8602
8612
  .map((logbook) => this.getPeriodByLogbook(logbook));
8603
8613
  // skip if the last logbook already included to the last existing date range
8604
- if (last(periods).end.toDate() < logbooks.last.date) {
8605
- // add extra date range for the last claimable logbook
8606
- periods.push(this.getPeriodByLogbook(logbooks.last, true));
8607
- }
8614
+ // if (last(periods).end.toDate() < logbooks.last.date) {
8615
+ // add extra date range for the last claimable logbook
8616
+ periods.push(this.getPeriodByLogbook(claimable.last, true));
8617
+ // }
8608
8618
  return periods;
8609
8619
  }
8610
8620
  /**
@@ -8618,8 +8628,8 @@ class BestVehicleLogbookCollection extends VehicleLogbookCollection {
8618
8628
  }
8619
8629
  return new DateRange([logbook.date, new Date(logbook.date.getTime() + BestVehicleLogbookCollection.periodDuration)]);
8620
8630
  }
8621
- static fromLogbooks(logbooks) {
8622
- const collection = new BestVehicleLogbookCollection(logbooks);
8631
+ static fromLogbooks(logbooks, isSole = false) {
8632
+ const collection = new BestVehicleLogbookCollection(logbooks, isSole);
8623
8633
  return collection.isBestPeriodExist(logbooks) ? collection : null;
8624
8634
  }
8625
8635
  }
@@ -10394,89 +10404,37 @@ __decorate([
10394
10404
  Type(() => TaxReturnItem)
10395
10405
  ], TaxReturn.prototype, "taxReturnItems", void 0);
10396
10406
 
10397
- // replace array element with the new one (only arrays of objects)
10398
- function replace(array, item, matchField = 'id') {
10399
- const index = array.findIndex((i) => i[matchField] === item[matchField]);
10400
- array.splice(index, 1, item);
10401
- }
10402
-
10403
- // sort array of objects by field
10404
- function sort(array, field = 'id', isDesc = true) {
10405
- array.sort((a, b) => {
10406
- if (a[field] > b[field]) {
10407
- return !isDesc ? 1 : -1;
10408
- }
10409
- if (a[field] < b[field]) {
10410
- return !isDesc ? -1 : 1;
10411
- }
10412
- return 0;
10413
- });
10414
- }
10415
-
10416
- // sort array of objects by field
10417
- function sortDeep(array, fieldsQueue = ['id'], isDesc = true) {
10418
- array.sort((a, b) => {
10419
- const aValue = getValue(a, fieldsQueue);
10420
- const bValue = getValue(b, fieldsQueue);
10421
- if (aValue > bValue) {
10422
- return !isDesc ? 1 : -1;
10423
- }
10424
- if (aValue < bValue) {
10425
- return !isDesc ? -1 : 1;
10426
- }
10427
- return 0;
10428
- });
10429
- }
10430
- function getValue(obj, fields) {
10431
- let value = obj;
10432
- fields.forEach((field) => {
10433
- value = value[field];
10434
- });
10435
- return value;
10436
- }
10437
-
10438
10407
  /**
10439
- * Convert single object or array into array
10408
+ * @TODO Alex (TT-1777): replace old logic with the new when all services ready
10409
+ * @TODO Alex (TT-1777): rename old logic and keep it for custom events
10440
10410
  */
10441
- function toArray(data) {
10442
- return Array.isArray(data) ? data : [data];
10443
- }
10444
-
10445
- class DataService {
10446
- /**
10447
- * @TODO use excludeExtraneousValues when all models refactored (exposed all needed properties)
10448
- * Create new instance of class
10449
- * @param model Single object or array from which will be created model instance(s)
10450
- */
10451
- createModelInstance(model) {
10452
- // excludePrefixes - class-transformer option is using to ignore hydra fields
10453
- return plainToClass(this.modelClass, model, { excludePrefixes: ['@'] });
10454
- }
10455
- createCollectionInstance(collectionClass, items) {
10456
- return new collectionClass(items);
10411
+ class EventDispatcherService {
10412
+ constructor() {
10413
+ this.eventSubject = new Subject();
10414
+ this.eventSubject2 = new Subject();
10457
10415
  }
10458
10416
  /**
10459
- * never return cache directly to prevent update
10417
+ * subscription to specific event type
10460
10418
  */
10461
- getCache() {
10462
- return clone(this.cache);
10419
+ on(eventType) {
10420
+ return this.eventSubject.pipe(filter((event) => [].concat(eventType).includes(event.type)), map((event) => event.payload));
10463
10421
  }
10464
- /**
10465
- * never return cache directly to prevent update
10466
- */
10467
- getCacheFirst() {
10468
- return clone(this.cache?.first);
10422
+ on2(...names) {
10423
+ return this.eventSubject2.pipe(filter((event) => [].concat(names).includes(event.name)), map((event) => event.items));
10469
10424
  }
10470
10425
  /**
10471
- * @TODO vik any[] because of problems with base models extending abstractModel
10426
+ * deliver new event
10472
10427
  */
10473
- setCache(data) {
10474
- this.cache = this.createCollectionInstance(this.collectionClass, data.map((item) => this.createModelInstance(item)));
10428
+ dispatch(event) {
10429
+ this.eventSubject.next(event);
10475
10430
  }
10476
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10477
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, providedIn: 'root' }); }
10431
+ dispatch2(event) {
10432
+ this.eventSubject2.next(event);
10433
+ }
10434
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10435
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, providedIn: 'root' }); }
10478
10436
  }
10479
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, decorators: [{
10437
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, decorators: [{
10480
10438
  type: Injectable,
10481
10439
  args: [{
10482
10440
  providedIn: 'root'
@@ -10533,43 +10491,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
10533
10491
  args: ['environment']
10534
10492
  }] }]; } });
10535
10493
 
10536
- /**
10537
- * @TODO Alex (TT-1777): replace old logic with the new when all services ready
10538
- * @TODO Alex (TT-1777): rename old logic and keep it for custom events
10539
- */
10540
- class EventDispatcherService {
10541
- constructor() {
10542
- this.eventSubject = new Subject();
10543
- this.eventSubject2 = new Subject();
10544
- }
10545
- /**
10546
- * subscription to specific event type
10547
- */
10548
- on(eventType) {
10549
- return this.eventSubject.pipe(filter((event) => [].concat(eventType).includes(event.type)), map((event) => event.payload));
10550
- }
10551
- on2(...names) {
10552
- return this.eventSubject2.pipe(filter((event) => [].concat(names).includes(event.name)), map((event) => event.items));
10553
- }
10554
- /**
10555
- * deliver new event
10556
- */
10557
- dispatch(event) {
10558
- this.eventSubject.next(event);
10559
- }
10560
- dispatch2(event) {
10561
- this.eventSubject2.next(event);
10562
- }
10563
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10564
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, providedIn: 'root' }); }
10565
- }
10566
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, decorators: [{
10567
- type: Injectable,
10568
- args: [{
10569
- providedIn: 'root'
10570
- }]
10571
- }] });
10572
-
10573
10494
  const NAME_TOKEN = 'token';
10574
10495
  const NAME_REFRESH_TOKEN = 'refreshToken';
10575
10496
  class JwtService extends JwtHelperService {
@@ -10654,66 +10575,234 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
10654
10575
  args: ['environment']
10655
10576
  }] }]; } });
10656
10577
 
10578
+ // replace array element with the new one (only arrays of objects)
10579
+ function replace(array, item, matchField = 'id') {
10580
+ const index = array.findIndex((i) => i[matchField] === item[matchField]);
10581
+ array.splice(index, 1, item);
10582
+ }
10583
+
10584
+ // sort array of objects by field
10585
+ function sort(array, field = 'id', isDesc = true) {
10586
+ array.sort((a, b) => {
10587
+ if (a[field] > b[field]) {
10588
+ return !isDesc ? 1 : -1;
10589
+ }
10590
+ if (a[field] < b[field]) {
10591
+ return !isDesc ? -1 : 1;
10592
+ }
10593
+ return 0;
10594
+ });
10595
+ }
10596
+
10597
+ // sort array of objects by field
10598
+ function sortDeep(array, fieldsQueue = ['id'], isDesc = true) {
10599
+ array.sort((a, b) => {
10600
+ const aValue = getValue(a, fieldsQueue);
10601
+ const bValue = getValue(b, fieldsQueue);
10602
+ if (aValue > bValue) {
10603
+ return !isDesc ? 1 : -1;
10604
+ }
10605
+ if (aValue < bValue) {
10606
+ return !isDesc ? -1 : 1;
10607
+ }
10608
+ return 0;
10609
+ });
10610
+ }
10611
+ function getValue(obj, fields) {
10612
+ let value = obj;
10613
+ fields.forEach((field) => {
10614
+ value = value[field];
10615
+ });
10616
+ return value;
10617
+ }
10618
+
10657
10619
  /**
10658
- * Abstract base service that implements common services functionality
10659
- * and describe abstract methods/properties that have to be implemented in child services
10660
- * Model - entity service is working with
10661
- * BaseModel - base entity model that extends by Model
10662
- * CollectionModel - entity collection class
10620
+ * Convert single object or array into array
10663
10621
  */
10664
- let RestService$1 = class RestService extends DataService {
10665
- constructor(http, eventDispatcherService, environment) {
10666
- super();
10667
- this.http = http;
10668
- this.eventDispatcherService = eventDispatcherService;
10669
- this.environment = environment;
10670
- /**
10671
- * Subject for service cache
10672
- */
10673
- this.cacheSubject = new ReplaySubject(1);
10674
- /**
10675
- * List of methods unavailable for current API
10676
- * @TODO Alex: add and handle enabled methods too
10677
- * @TODO Alex: disable batch by default
10678
- */
10679
- this.disabledMethods = [];
10680
- this.mpService = inject(MixpanelService);
10681
- this.roles = [];
10682
- // @TODO Alex remove, bad idea to call empty method overrided in child (because it will be called with parent context)
10683
- this.listenEvents();
10622
+ function toArray(data) {
10623
+ return Array.isArray(data) ? data : [data];
10624
+ }
10625
+
10626
+ class DataService {
10627
+ /**
10628
+ * @TODO use excludeExtraneousValues when all models refactored (exposed all needed properties)
10629
+ * Create new instance of class
10630
+ * @param model Single object or array from which will be created model instance(s)
10631
+ */
10632
+ createModelInstance(model) {
10633
+ // excludePrefixes - class-transformer option is using to ignore hydra fields
10634
+ return plainToClass(this.modelClass, model, { excludePrefixes: ['@'] });
10684
10635
  }
10685
- get apiUrl() {
10686
- return `${this.environment.apiV2}/${this.endpointUri}`;
10636
+ createCollectionInstance(collectionClass, items) {
10637
+ return new collectionClass(items);
10687
10638
  }
10688
- setCache(data, next = false) {
10689
- super.setCache(data);
10690
- if (next) {
10691
- this.cacheSubject.next(this.cache);
10692
- }
10639
+ /**
10640
+ * never return cache directly to prevent update
10641
+ */
10642
+ getCache() {
10643
+ return clone(this.cache);
10693
10644
  }
10694
10645
  /**
10695
- * Refresh cache with actual backend data
10646
+ * never return cache directly to prevent update
10696
10647
  */
10697
- refreshCache() {
10698
- this.cache = undefined;
10699
- this.get();
10648
+ getCacheFirst() {
10649
+ return clone(this.cache?.first);
10700
10650
  }
10701
10651
  /**
10702
- * Get data from backend and fill the cache
10652
+ * @TODO vik any[] because of problems with base models extending abstractModel
10703
10653
  */
10704
- fetch(path = this.apiUrl) {
10705
- this.handleAccessError('get');
10706
- if (!this.hasRoles()) {
10707
- this.setCache([], true);
10708
- return this.cacheSubject.asObservable();
10709
- }
10710
- // Set cache as empty collection to avoid multiple requests before cache filled
10711
- this.setCache([]);
10712
- return this.http.get(path)
10713
- .pipe(map((response) => this.isApiPlatform ? response['hydra:member'] : toArray(response)), map((response) => {
10714
- this.setCache(response, true);
10715
- return this.cache;
10716
- }));
10654
+ setCache(data) {
10655
+ this.cache = this.createCollectionInstance(this.collectionClass, data.map((item) => this.createModelInstance(item)));
10656
+ }
10657
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10658
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, providedIn: 'root' }); }
10659
+ }
10660
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, decorators: [{
10661
+ type: Injectable,
10662
+ args: [{
10663
+ providedIn: 'root'
10664
+ }]
10665
+ }] });
10666
+
10667
+ /**
10668
+ * Common toast message class
10669
+ */
10670
+ class Toast {
10671
+ constructor() {
10672
+ this.duration = 3000;
10673
+ this.autoClose = true;
10674
+ }
10675
+ }
10676
+
10677
+ var ToastTypeEnum;
10678
+ (function (ToastTypeEnum) {
10679
+ ToastTypeEnum[ToastTypeEnum["INFO"] = 0] = "INFO";
10680
+ ToastTypeEnum[ToastTypeEnum["SUCCESS"] = 1] = "SUCCESS";
10681
+ ToastTypeEnum[ToastTypeEnum["WARNING"] = 2] = "WARNING";
10682
+ ToastTypeEnum[ToastTypeEnum["ERROR"] = 3] = "ERROR";
10683
+ })(ToastTypeEnum || (ToastTypeEnum = {}));
10684
+
10685
+ /**
10686
+ * popup notifications service (toast, snackbar).
10687
+ */
10688
+ class ToastService {
10689
+ constructor() {
10690
+ this.toast$ = new ReplaySubject(1);
10691
+ }
10692
+ get() {
10693
+ return this.toast$.asObservable();
10694
+ }
10695
+ add(toast) {
10696
+ // set date to prevent closing of equal toasts (extra case)
10697
+ toast.date = new Date(),
10698
+ this.toast$.next(toast);
10699
+ }
10700
+ success(message) {
10701
+ this.add(plainToClass(Toast, {
10702
+ type: ToastTypeEnum.SUCCESS,
10703
+ title: 'Success!',
10704
+ message,
10705
+ }));
10706
+ }
10707
+ warning(message) {
10708
+ this.add(plainToClass(Toast, {
10709
+ type: ToastTypeEnum.WARNING,
10710
+ title: 'Notification!',
10711
+ message,
10712
+ }));
10713
+ }
10714
+ error(message) {
10715
+ this.add(plainToClass(Toast, {
10716
+ type: ToastTypeEnum.ERROR,
10717
+ title: 'Error!',
10718
+ message,
10719
+ }));
10720
+ }
10721
+ info(message) {
10722
+ this.add(plainToClass(Toast, {
10723
+ type: ToastTypeEnum.INFO,
10724
+ title: 'Information',
10725
+ message,
10726
+ }));
10727
+ }
10728
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10729
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, providedIn: 'root' }); }
10730
+ }
10731
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, decorators: [{
10732
+ type: Injectable,
10733
+ args: [{
10734
+ providedIn: 'root'
10735
+ }]
10736
+ }] });
10737
+
10738
+ /**
10739
+ * Abstract base service that implements common services functionality
10740
+ * and describe abstract methods/properties that have to be implemented in child services
10741
+ * Model - entity service is working with
10742
+ * BaseModel - base entity model that extends by Model
10743
+ * CollectionModel - entity collection class
10744
+ */
10745
+ let RestService$1 = class RestService extends DataService {
10746
+ constructor(http, eventDispatcherService, environment) {
10747
+ super();
10748
+ this.http = http;
10749
+ this.eventDispatcherService = eventDispatcherService;
10750
+ this.environment = environment;
10751
+ /**
10752
+ * Subject for service cache
10753
+ */
10754
+ this.cacheSubject = new ReplaySubject(1);
10755
+ /**
10756
+ * List of methods unavailable for current API
10757
+ * @TODO Alex: add and handle enabled methods too
10758
+ * @TODO Alex: disable batch by default
10759
+ */
10760
+ this.disabledMethods = [];
10761
+ this.mpService = inject(MixpanelService);
10762
+ this.sseService = inject(SseService);
10763
+ this.toastService = inject(ToastService);
10764
+ this.roles = [];
10765
+ /**
10766
+ * disable cache update by requests, update only by SSE events
10767
+ */
10768
+ this.disableCache = false;
10769
+ // @TODO Alex remove, bad idea to call empty method overrided in child (because it will be called with parent context)
10770
+ this.listenEvents();
10771
+ // @TODO Alex remove, bad idea to call empty method overrided in child (because it will be called with parent context)
10772
+ this.listenSSE();
10773
+ }
10774
+ get apiUrl() {
10775
+ return `${this.environment.apiV2}/${this.endpointUri}`;
10776
+ }
10777
+ setCache(data, next = false) {
10778
+ super.setCache(data);
10779
+ if (next) {
10780
+ this.cacheSubject.next(this.cache);
10781
+ }
10782
+ }
10783
+ /**
10784
+ * Refresh cache with actual backend data
10785
+ */
10786
+ refreshCache() {
10787
+ this.cache = undefined;
10788
+ this.get();
10789
+ }
10790
+ /**
10791
+ * Get data from backend and fill the cache
10792
+ */
10793
+ fetch(path = this.apiUrl) {
10794
+ this.handleAccessError('get');
10795
+ if (!this.hasRoles()) {
10796
+ this.setCache([], true);
10797
+ return this.cacheSubject.asObservable();
10798
+ }
10799
+ // Set cache as empty collection to avoid multiple requests before cache filled
10800
+ this.setCache([]);
10801
+ return this.http.get(path)
10802
+ .pipe(map((response) => this.isApiPlatform ? response['hydra:member'] : toArray(response)), map((response) => {
10803
+ this.setCache(response, true);
10804
+ return this.cache;
10805
+ }));
10717
10806
  }
10718
10807
  get(path = this.apiUrl) {
10719
10808
  if (!this.cache) {
@@ -10725,6 +10814,9 @@ let RestService$1 = class RestService extends DataService {
10725
10814
  this.handleAccessError('get');
10726
10815
  return this.get().pipe(map((collection) => collection.first));
10727
10816
  }
10817
+ hasInCache(id) {
10818
+ return !!this.getCache().findBy('id', id);
10819
+ }
10728
10820
  getArray() {
10729
10821
  return this.get().pipe(map((collection) => collection.toArray()));
10730
10822
  }
@@ -10815,6 +10907,10 @@ let RestService$1 = class RestService extends DataService {
10815
10907
  }));
10816
10908
  }
10817
10909
  track(response, method, mpData, postfix = '') {
10910
+ // check if result exist, sometimes response may be empty (for example ClientInvite accept/reject/etc)
10911
+ if (!response[0]) {
10912
+ return;
10913
+ }
10818
10914
  // no other way to check interface
10819
10915
  if ('getMpData' in response[0]) {
10820
10916
  response.forEach((model) => {
@@ -10831,7 +10927,7 @@ let RestService$1 = class RestService extends DataService {
10831
10927
  */
10832
10928
  handleResponse(response, method, mpData) {
10833
10929
  this.track(response, method, mpData);
10834
- if (this.getCache()) {
10930
+ if (this.getCache() && !this.disableCache) {
10835
10931
  this.updateCache(response, method);
10836
10932
  }
10837
10933
  // dispatch event for interested services
@@ -10908,6 +11004,10 @@ let RestService$1 = class RestService extends DataService {
10908
11004
  * Method that call all listeners. Empty by default. Should be redefined by child services if required
10909
11005
  */
10910
11006
  listenEvents() { }
11007
+ /**
11008
+ * Listen SSE events
11009
+ */
11010
+ listenSSE() { }
10911
11011
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RestService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
10912
11012
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RestService, providedIn: 'root' }); }
10913
11013
  };
@@ -11014,89 +11114,17 @@ var BankConnectionMessagesEnum;
11014
11114
  BankConnectionMessagesEnum["TEMPORARY_UNAVAILABLE"] = "The bank is temporarily unavailable, please check back later";
11015
11115
  })(BankConnectionMessagesEnum || (BankConnectionMessagesEnum = {}));
11016
11116
 
11017
- /**
11018
- * Common toast message class
11019
- */
11020
- class Toast {
11021
- constructor() {
11022
- this.duration = 3000;
11023
- this.autoClose = true;
11024
- }
11025
- }
11026
-
11027
- var ToastTypeEnum;
11028
- (function (ToastTypeEnum) {
11029
- ToastTypeEnum[ToastTypeEnum["INFO"] = 0] = "INFO";
11030
- ToastTypeEnum[ToastTypeEnum["SUCCESS"] = 1] = "SUCCESS";
11031
- ToastTypeEnum[ToastTypeEnum["WARNING"] = 2] = "WARNING";
11032
- ToastTypeEnum[ToastTypeEnum["ERROR"] = 3] = "ERROR";
11033
- })(ToastTypeEnum || (ToastTypeEnum = {}));
11034
-
11035
- /**
11036
- * popup notifications service (toast, snackbar).
11037
- */
11038
- class ToastService {
11039
- constructor() {
11040
- this.toast$ = new ReplaySubject(1);
11041
- }
11042
- get() {
11043
- return this.toast$.asObservable();
11044
- }
11045
- add(toast) {
11046
- // set date to prevent closing of equal toasts (extra case)
11047
- toast.date = new Date(),
11048
- this.toast$.next(toast);
11049
- }
11050
- success(message) {
11051
- this.add(plainToClass(Toast, {
11052
- type: ToastTypeEnum.SUCCESS,
11053
- title: 'Success!',
11054
- message,
11055
- }));
11056
- }
11057
- warning(message) {
11058
- this.add(plainToClass(Toast, {
11059
- type: ToastTypeEnum.WARNING,
11060
- title: 'Notification!',
11061
- message,
11062
- }));
11063
- }
11064
- error(message) {
11065
- this.add(plainToClass(Toast, {
11066
- type: ToastTypeEnum.ERROR,
11067
- title: 'Error!',
11068
- message,
11069
- }));
11070
- }
11071
- info(message) {
11072
- this.add(plainToClass(Toast, {
11073
- type: ToastTypeEnum.INFO,
11074
- title: 'Information',
11075
- message,
11076
- }));
11077
- }
11078
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
11079
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, providedIn: 'root' }); }
11080
- }
11081
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, decorators: [{
11082
- type: Injectable,
11083
- args: [{
11084
- providedIn: 'root'
11085
- }]
11086
- }] });
11087
-
11088
11117
  /**
11089
11118
  * BankConnection means user account at specific bank (usually each user has only one at the same bank)
11090
11119
  * service handles BankConnection management
11091
11120
  */
11092
11121
  class BankConnectionService extends RestService$1 {
11093
- constructor(http, eventDispatcherService, sseService, environment, toastService) {
11122
+ constructor(http, eventDispatcherService, sseService, environment) {
11094
11123
  super(http, eventDispatcherService, environment);
11095
11124
  this.http = http;
11096
11125
  this.eventDispatcherService = eventDispatcherService;
11097
11126
  this.sseService = sseService;
11098
11127
  this.environment = environment;
11099
- this.toastService = toastService;
11100
11128
  this.isApiPlatform = true;
11101
11129
  this.modelClass = BankConnection;
11102
11130
  this.collectionClass = Collection;
@@ -11155,7 +11183,7 @@ class BankConnectionService extends RestService$1 {
11155
11183
  this.refreshCache();
11156
11184
  });
11157
11185
  }
11158
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BankConnectionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }, { token: ToastService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11186
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BankConnectionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
11159
11187
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BankConnectionService, providedIn: 'root' }); }
11160
11188
  }
11161
11189
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BankConnectionService, decorators: [{
@@ -11166,7 +11194,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11166
11194
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
11167
11195
  type: Inject,
11168
11196
  args: ['environment']
11169
- }] }, { type: ToastService }]; } });
11197
+ }] }]; } });
11170
11198
 
11171
11199
  var UserEventTypeTypeEnum;
11172
11200
  (function (UserEventTypeTypeEnum) {
@@ -11569,12 +11597,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11569
11597
  * Service for work with chats
11570
11598
  */
11571
11599
  class ChatService extends RestService$1 {
11572
- constructor(http, eventDispatcherService, environment, sseService) {
11600
+ constructor(http, eventDispatcherService, environment) {
11573
11601
  super(http, eventDispatcherService, environment);
11574
11602
  this.http = http;
11575
11603
  this.eventDispatcherService = eventDispatcherService;
11576
11604
  this.environment = environment;
11577
- this.sseService = sseService;
11578
11605
  this.modelClass = Chat;
11579
11606
  this.collectionClass = ChatCollection;
11580
11607
  this.endpointUri = 'chats';
@@ -11630,7 +11657,7 @@ class ChatService extends RestService$1 {
11630
11657
  this.handleResponse([updatedChat], 'put');
11631
11658
  });
11632
11659
  }
11633
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChatService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: SseService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11660
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChatService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
11634
11661
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChatService, providedIn: 'root' }); }
11635
11662
  }
11636
11663
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChatService, decorators: [{
@@ -11641,18 +11668,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11641
11668
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11642
11669
  type: Inject,
11643
11670
  args: ['environment']
11644
- }] }, { type: SseService }]; } });
11671
+ }] }]; } });
11645
11672
 
11646
11673
  /**
11647
11674
  * Service for work with messages
11648
11675
  */
11649
11676
  class MessageService extends RestService$1 {
11650
- constructor(http, eventDispatcherService, environment, sseService) {
11677
+ constructor(http, eventDispatcherService, environment) {
11651
11678
  super(http, eventDispatcherService, environment);
11652
11679
  this.http = http;
11653
11680
  this.eventDispatcherService = eventDispatcherService;
11654
11681
  this.environment = environment;
11655
- this.sseService = sseService;
11656
11682
  this.modelClass = Message;
11657
11683
  this.collectionClass = MessageCollection;
11658
11684
  this.endpointUri = 'messages';
@@ -11689,7 +11715,7 @@ class MessageService extends RestService$1 {
11689
11715
  }
11690
11716
  });
11691
11717
  }
11692
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: SseService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11718
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
11693
11719
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageService, providedIn: 'root' }); }
11694
11720
  }
11695
11721
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageService, decorators: [{
@@ -11700,7 +11726,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11700
11726
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11701
11727
  type: Inject,
11702
11728
  args: ['environment']
11703
- }] }, { type: SseService }]; } });
11729
+ }] }]; } });
11704
11730
 
11705
11731
  /**
11706
11732
  * Service for work with Message Documents
@@ -12157,32 +12183,229 @@ class FileService extends RestService$1 {
12157
12183
  formData.append('file', file);
12158
12184
  return this.http.post(this.apiUrl, formData).pipe(map((fileBase) => plainToClass(AppFile, fileBase)));
12159
12185
  }
12160
- download(file) {
12161
- return this.http.get(`${this.apiUrl}/${file.id}/download`, { responseType: 'blob' });
12186
+ download(file) {
12187
+ return this.http.get(`${this.apiUrl}/${file.id}/download`, { responseType: 'blob' });
12188
+ }
12189
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12190
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, providedIn: 'root' }); }
12191
+ }
12192
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, decorators: [{
12193
+ type: Injectable,
12194
+ args: [{
12195
+ providedIn: 'root'
12196
+ }]
12197
+ }] });
12198
+
12199
+ class ClientIncomeTypesService extends RestService$1 {
12200
+ constructor() {
12201
+ super(...arguments);
12202
+ this.modelClass = ClientIncomeTypes;
12203
+ this.collectionClass = Collection;
12204
+ this.endpointUri = 'client-income-types';
12205
+ this.isApiPlatform = true;
12206
+ this.disabledMethods = ['postBatch', 'putBatch', 'delete', 'deleteBatch'];
12207
+ }
12208
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12209
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, providedIn: 'root' }); }
12210
+ }
12211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, decorators: [{
12212
+ type: Injectable,
12213
+ args: [{
12214
+ providedIn: 'root'
12215
+ }]
12216
+ }] });
12217
+
12218
+ class ClientInviteService extends RestService$1 {
12219
+ constructor() {
12220
+ super(...arguments);
12221
+ this.endpointUri = 'clients/invites';
12222
+ this.collectionClass = ClientInviteCollection;
12223
+ this.modelClass = ClientInvite;
12224
+ }
12225
+ getFirmInvites() {
12226
+ return super.get(`${this.apiUrl}/all`);
12227
+ }
12228
+ /**
12229
+ * Get invite which employee is TaxTank Advisor
12230
+ * @TODO move to collection? but we need to inject enviroment
12231
+ */
12232
+ getTTAdvisor() {
12233
+ return this.get().pipe(map((invites) => invites.findBy('employee.email', this.environment.ttAdvisor)));
12234
+ }
12235
+ /**
12236
+ * Import clients from CSV file
12237
+ */
12238
+ import(file) {
12239
+ const formData = new FormData();
12240
+ formData.append('file', file);
12241
+ // cant use parent method because of different parameters
12242
+ return this.http.post(`${this.apiUrl}/import`, formData).pipe(map((clientInvite) => clientInvite));
12243
+ }
12244
+ /**
12245
+ * Accept client invitation from firm to user
12246
+ */
12247
+ accept(invite) {
12248
+ // cant use parent method because of custom specific handler
12249
+ return this.http.put(`${this.apiUrl}/${invite.id}/accept`, invite).pipe(map(() => {
12250
+ // @TODO remove when TaxReviewService refactored with the new rest and use there listenCSE instead
12251
+ // TaxReviewService is listening client invites acception. With the new rest we are using listenCSE method, but old rest does not have this method.
12252
+ // We need to refactor TaxReviewService with new rest first, then we can listenCSE and remove manual events
12253
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_INVITE_ACCEPTED, null));
12254
+ this.handleResponse([invite], 'delete');
12255
+ }));
12256
+ }
12257
+ /**
12258
+ * Reject client invitation from firm to user
12259
+ */
12260
+ reject(invite) {
12261
+ return super.put(invite, null, `${this.apiUrl}/${invite.id}/reject`);
12262
+ }
12263
+ /**
12264
+ * Resend invitation from firm to client
12265
+ */
12266
+ resend(invite) {
12267
+ // cant use parent method because of custom specific handler
12268
+ return this.http.post(`${this.apiUrl}/${invite.id}/resend`, null)
12269
+ .pipe(map((inviteBase) => plainToClass(ClientInvite, inviteBase)), map((resentInvite) => {
12270
+ this.handleResponse([resentInvite], 'put');
12271
+ return resentInvite;
12272
+ }));
12273
+ }
12274
+ /**
12275
+ * Send invitation from client to firm
12276
+ */
12277
+ inviteFirmByUser(invite) {
12278
+ return super.post(invite, null, `${this.environment.apiV2}/firms/invite`)
12279
+ .pipe(catchError((error) => {
12280
+ if (error.error.email) {
12281
+ this.toastService.error(error.error.email[0]);
12282
+ }
12283
+ else {
12284
+ this.toastService.error(error.error);
12285
+ }
12286
+ return throwError(error);
12287
+ }));
12288
+ }
12289
+ /**
12290
+ * Listem clientInvites db changes via mercure to update cache
12291
+ * @TODO make it universal and move to parent
12292
+ */
12293
+ listenSSE() {
12294
+ this.sseService.on('clientInvites')
12295
+ .pipe(map((clientInvite) => plainToClass(ClientInvite, clientInvite)))
12296
+ .subscribe((clientInvite) => {
12297
+ // we got empty body when item deleted so we should get id from Api Platform data (@id)
12298
+ const id = clientInvite.id ?? +last(clientInvite['@id'].split('/'));
12299
+ switch (true) {
12300
+ case !clientInvite.id:
12301
+ this.updateCache([merge(clientInvite, { id })], 'delete');
12302
+ break;
12303
+ case this.hasInCache(id):
12304
+ this.updateCache([clientInvite], 'put');
12305
+ break;
12306
+ case !this.hasInCache(id):
12307
+ this.updateCache([clientInvite], 'post');
12308
+ }
12309
+ });
12162
12310
  }
12163
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12164
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, providedIn: 'root' }); }
12311
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12312
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, providedIn: 'root' }); }
12165
12313
  }
12166
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, decorators: [{
12314
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, decorators: [{
12167
12315
  type: Injectable,
12168
12316
  args: [{
12169
12317
  providedIn: 'root'
12170
12318
  }]
12171
12319
  }] });
12172
12320
 
12173
- class ClientIncomeTypesService extends RestService$1 {
12321
+ var ClientInviteMessages;
12322
+ (function (ClientInviteMessages) {
12323
+ ClientInviteMessages["TT_ADVISOR_INVITED"] = "You have Invited TaxTank Support successfully";
12324
+ ClientInviteMessages["TT_INVITE_ACCEPT"] = "You successfully accepted the invitation";
12325
+ ClientInviteMessages["REVOKE_TT_ADVISOR_CONFIRM"] = "Are you sure you want to revoke access?";
12326
+ ClientInviteMessages["TT_ADVISOR_REVOKED"] = "Access revoked";
12327
+ ClientInviteMessages["SEND_INVITE_MESSAGES_TITLE"] = "TaxTank support is here to help";
12328
+ ClientInviteMessages["SEND_INVITE_MESSAGES_DESCRIPTION"] = "Before inviting TaxTank support be sure to check out our help articles and message our support team.";
12329
+ ClientInviteMessages["TT_ACCOUNTANT_INVITED"] = "Accountant invitation has been sent successfully";
12330
+ ClientInviteMessages["TT_ACCOUNTANT_INVETED_TOOLTIP"] = "Need an accountant? TaxTank Accountants delivers virtual accounting service exclusive to TaxTank subscribers. Experience a fast, seamless, and cost-effective lodgement service that rewards your TaxTank efforts throughout the year. Our team of experienced accountants brings their expertise in tax and TaxTank to the virtual realm. It all starts with a 15-minute consultation that sets the stage for personalised service. With us, you\u2019ll receive the best of both worlds at tax time.";
12331
+ ClientInviteMessages["CONFIRM_REJECT"] = "Are you sure you want to reject this invitation?";
12332
+ ClientInviteMessages["REJECTED"] = "Invitation rejected";
12333
+ ClientInviteMessages["ACCEPTED"] = "Client invitation accepted";
12334
+ })(ClientInviteMessages || (ClientInviteMessages = {}));
12335
+
12336
+ class ClientMovementService extends RestService$1 {
12174
12337
  constructor() {
12175
12338
  super(...arguments);
12176
- this.modelClass = ClientIncomeTypes;
12177
- this.collectionClass = Collection;
12178
- this.endpointUri = 'client-income-types';
12339
+ this.endpointUri = 'client-movements';
12340
+ this.collectionClass = ClientMovementCollection;
12341
+ this.modelClass = ClientMovement;
12179
12342
  this.isApiPlatform = true;
12180
- this.disabledMethods = ['postBatch', 'putBatch', 'delete', 'deleteBatch'];
12343
+ this.disabledMethods = ['postBatch', 'delete', 'deleteBatch'];
12181
12344
  }
12182
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12183
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, providedIn: 'root' }); }
12345
+ listenEvents() {
12346
+ // @TODO handle with mercure
12347
+ this.listenCSE(ClientInvite, ['post', 'put', 'delete'], this.refreshCache);
12348
+ }
12349
+ getActive() {
12350
+ return this.get().pipe(map((clientMovements) => clientMovements.active));
12351
+ }
12352
+ getTTAdvisor() {
12353
+ return this.getActive()
12354
+ .pipe(map((movements) => movements.findBy('employee.email', this.environment.ttAdvisor) || null));
12355
+ }
12356
+ getActiveByFirmType(type) {
12357
+ return this.getActive().pipe(map((clientMovements) => clientMovements.getByFirmType(type)));
12358
+ }
12359
+ /**
12360
+ * Method is using for transfer client between employees.
12361
+ * On backend we close passed movement and create a new one instead
12362
+ */
12363
+ put(movement) {
12364
+ // extend base 'add' method and pass into it movement without id
12365
+ return super.post(plainToClass(ClientMovement, Object.assign({}, movement, { id: null }))).pipe(map((updatedMovement) => {
12366
+ // remove provided movement from cache
12367
+ this.cache = this.cache.filter((item) => item.id !== movement.id);
12368
+ this.updateCache([updatedMovement], 'post');
12369
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_TRANSFER_TO_OTHER_EMPLOYEE, [updatedMovement.client]));
12370
+ return updatedMovement;
12371
+ }));
12372
+ }
12373
+ /**
12374
+ * There is no actually direct updating of client movement, but we are using this method for transfer clients between employees
12375
+ */
12376
+ putBatch(clientMovements) {
12377
+ const batch = clientMovements.map((clientMovement) => this.put(clientMovement));
12378
+ return forkJoin(batch);
12379
+ }
12380
+ /**
12381
+ * Reject current firm
12382
+ */
12383
+ close(clientMovement) {
12384
+ clientMovement.dateTo = new Date();
12385
+ // cant use parent method because of custom specific handler
12386
+ return this.http.put(`${this.environment.apiV2}/client-movements/${clientMovement.id}/close`, clientMovement)
12387
+ .pipe(map(() => {
12388
+ // @TODO remove when TaxReviewService refactored with the new rest and use there listenCSE instead
12389
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_MOVEMENT_CLOSED, null));
12390
+ this.cache = this.cache.filter((movement) => movement.id !== clientMovement.id);
12391
+ this.updateCache([clientMovement], 'delete');
12392
+ }));
12393
+ }
12394
+ /**
12395
+ * Listem clientMovements db changes via mercure to update cache
12396
+ * @TODO make it universal and move to parent
12397
+ */
12398
+ listenSSE() {
12399
+ this.sseService.on('clientMovements')
12400
+ .pipe(map((clientMovement) => plainToClass(ClientMovement, clientMovement)))
12401
+ .subscribe((clientMovement) => {
12402
+ this.hasInCache(clientMovement.id) ? this.updateCache([clientMovement], 'put') : this.updateCache([clientMovement], 'post');
12403
+ });
12404
+ }
12405
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12406
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, providedIn: 'root' }); }
12184
12407
  }
12185
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, decorators: [{
12408
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, decorators: [{
12186
12409
  type: Injectable,
12187
12410
  args: [{
12188
12411
  providedIn: 'root'
@@ -12414,207 +12637,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
12414
12637
  args: ['environment']
12415
12638
  }] }, { type: ToastService }]; } });
12416
12639
 
12417
- class ClientInviteService extends RestService {
12418
- constructor() {
12419
- super(...arguments);
12420
- this.url = 'clients/invites';
12421
- this.modelClass = ClientInvite;
12422
- }
12423
- listenEvents() {
12424
- this.listenNotifications();
12425
- }
12426
- getFirmInvites() {
12427
- return super.get(`${this.environment.apiV2}/${this.url}/all`);
12428
- }
12429
- getTTAdvisor() {
12430
- return this.get()
12431
- .pipe(map((invites) => new ClientInviteCollection(invites).findBy('employee.email', this.environment.ttAdvisor) || null));
12432
- }
12433
- /**
12434
- * Import employees for firm from CSV file
12435
- * @param file
12436
- */
12437
- import(file) {
12438
- const formData = new FormData();
12439
- formData.append('file', file);
12440
- return this.http.post(`${this.environment.apiV2}/${this.url}/import`, formData)
12441
- .pipe(map((clientInvite) => clientInvite));
12442
- }
12443
- /**
12444
- * Accept client invitation from firm to user
12445
- * @param invite
12446
- */
12447
- accept(invite) {
12448
- return this.http.post(`${this.environment.apiV2}/${this.url}/${invite.id}/accept`, null)
12449
- .pipe(map(() => {
12450
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_INVITE_ACCEPTED, invite));
12451
- // set cache without accepted invite
12452
- this.cache = this.cache.filter((clientInvite) => invite.id !== clientInvite.id);
12453
- this.updateCache();
12454
- }));
12455
- }
12456
- /**
12457
- * Reject client invitation from firm to user
12458
- * @param invite
12459
- */
12460
- reject(invite) {
12461
- return this.http.post(`${this.environment.apiV2}/${this.url}/${invite.id}/reject`, null)
12462
- .pipe(map((rejectedInvite) => {
12463
- const updatedInvite = plainToClass(ClientInvite, rejectedInvite);
12464
- // avoid cache changes
12465
- // @TODO make cache readonly
12466
- const tempCache = cloneDeep$1(this.cache);
12467
- replace(tempCache, plainToClass(ClientInvite, updatedInvite));
12468
- this.cache = tempCache;
12469
- this.updateCache();
12470
- return updatedInvite;
12471
- }));
12472
- }
12473
- /**
12474
- * Resend invitation from firm to client
12475
- * @param invite
12476
- */
12477
- resend(invite) {
12478
- return this.http.post(`${this.environment.apiV2}/${this.url}/${invite.id}/resend`, null)
12479
- .pipe(map((rejectedInvite) => {
12480
- const updatedInvite = plainToClass(ClientInvite, rejectedInvite);
12481
- // avoid cache changes
12482
- // @TODO make cache readonly
12483
- const tempCache = cloneDeep$1(this.cache);
12484
- replace(tempCache, plainToClass(ClientInvite, updatedInvite));
12485
- this.cache = tempCache;
12486
- this.updateCache();
12487
- return updatedInvite;
12488
- }));
12489
- }
12490
- /**
12491
- * Send invitation from client to firm
12492
- * @param invite
12493
- */
12494
- inviteFirmByUser(invite) {
12495
- return this.http.post(`${this.environment.apiV2}/firms/invite`, invite)
12496
- .pipe(map((inviteBase) => {
12497
- const newInvite = plainToClass(ClientInvite, inviteBase);
12498
- // avoid cache changes
12499
- // @TODO make cache readonly
12500
- const tempCache = cloneDeep$1(this.cache);
12501
- tempCache.push(newInvite);
12502
- this.cache = tempCache;
12503
- this.updateCache();
12504
- return newInvite;
12505
- }));
12506
- }
12507
- /**
12508
- * Reset cache on client/firm invite events
12509
- */
12510
- listenNotifications() {
12511
- this.eventDispatcherService.on(AppEventTypeEnum.NOTIFICATION_ADDED).subscribe((notification) => {
12512
- if (!notification.isRead && (notification.eventType === UserEventTypeTypeEnum.FIRM_INVITE_ACCEPTED || notification.eventType === UserEventTypeTypeEnum.CLIENT_INVITE)) {
12513
- this.refreshCache();
12514
- }
12515
- });
12516
- }
12517
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12518
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, providedIn: 'root' }); }
12519
- }
12520
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, decorators: [{
12521
- type: Injectable,
12522
- args: [{
12523
- providedIn: 'root'
12524
- }]
12525
- }] });
12526
-
12527
- var ClientInviteMessages;
12528
- (function (ClientInviteMessages) {
12529
- ClientInviteMessages["TT_ADVISOR_INVITED"] = "You have Invited TaxTank Support successfully";
12530
- ClientInviteMessages["REVOKE_TT_ADVISOR_CONFIRM"] = "Are you sure you want to revoke access?";
12531
- ClientInviteMessages["TT_ADVISOR_REVOKED"] = "Access revoked";
12532
- ClientInviteMessages["TT_INVITE_ACCEPT"] = "You successfully accepted the invitation";
12533
- ClientInviteMessages["SEND_INVITE_MESSAGES_TITLE"] = "TaxTank support is here to help";
12534
- ClientInviteMessages["SEND_INVITE_MESSAGES_DESCRIPTION"] = "Before inviting TaxTank support be sure to check out our help articles and message our support team.";
12535
- ClientInviteMessages["TT_ACCOUNTANT_INVITED"] = "Accountant invitation has been sent successfully";
12536
- ClientInviteMessages["TT_ACCOUNTANT_INVETED_TOOLTIP"] = "Need an accountant? TaxTank Accountants delivers virtual accounting service exclusive to TaxTank subscribers. Experience a fast, seamless, and cost-effective lodgement service that rewards your TaxTank efforts throughout the year. Our team of experienced accountants brings their expertise in tax and TaxTank to the virtual realm. It all starts with a 15-minute consultation that sets the stage for personalised service. With us, you\u2019ll receive the best of both worlds at tax time.";
12537
- })(ClientInviteMessages || (ClientInviteMessages = {}));
12538
-
12539
- class ClientMovementService extends RestService {
12540
- constructor() {
12541
- super(...arguments);
12542
- this.modelClass = ClientMovement;
12543
- this.url = 'client-movements';
12544
- this.isHydra = true;
12545
- }
12546
- listenEvents() {
12547
- this.listenNotifications();
12548
- this.listenClientInvites();
12549
- }
12550
- /**
12551
- * @TODO BaseRestService should return collection
12552
- */
12553
- getAll() {
12554
- return this.get().pipe(map((clientMovements) => new ClientMovementCollection(clientMovements)));
12555
- }
12556
- getActive() {
12557
- return this.getAll().pipe(map((clientMovements) => clientMovements.active));
12558
- }
12559
- getTTAdvisor() {
12560
- return this.getActive()
12561
- .pipe(map((movements) => movements.findBy('employee.email', this.environment.ttAdvisor) || null));
12562
- }
12563
- getActiveByFirmType(type) {
12564
- return this.getActive().pipe(map((clientMovements) => clientMovements.getByFirmType(type)));
12565
- }
12566
- update(movement) {
12567
- // extend base 'add' method and pass into it movement without id
12568
- return super.add(plainToClass(ClientMovement, Object.assign({}, movement, { id: null }))).pipe(map((updatedMovement) => {
12569
- // remove provided movement from cache
12570
- this.cache = this.cache.filter((item) => item.id !== movement.id);
12571
- this.updateCache();
12572
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_TRANSFER_TO_OTHER_EMPLOYEE, [updatedMovement.client]));
12573
- return updatedMovement;
12574
- }));
12575
- }
12576
- updateBatch(clientMovements) {
12577
- const batch = clientMovements.map((clientMovement) => this.update(clientMovement));
12578
- return forkJoin(batch);
12579
- }
12580
- /**
12581
- * Reject current firm
12582
- */
12583
- close(clientMovement) {
12584
- clientMovement.dateTo = new Date();
12585
- return this.http.put(`${this.environment.apiV2}/client-movements/${clientMovement.id}/close`, clientMovement)
12586
- .pipe(map(() => {
12587
- this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_MOVEMENT_CLOSED, null));
12588
- this.cache = this.cache.filter((movement) => movement.id !== clientMovement.id);
12589
- this.updateCache();
12590
- }));
12591
- }
12592
- listenNotifications() {
12593
- this.eventDispatcherService.on(AppEventTypeEnum.NOTIFICATION_ADDED).subscribe((notification) => {
12594
- if (!notification.isRead && notification.eventType === UserEventTypeTypeEnum.FIRM_INVITE_ACCEPTED) {
12595
- this.refreshCache();
12596
- }
12597
- });
12598
- }
12599
- /**
12600
- * Listen to EventDispatcherService event related to clients invitations
12601
- */
12602
- listenClientInvites() {
12603
- this.eventDispatcherService.on(AppEventTypeEnum.CLIENT_INVITE_ACCEPTED)
12604
- .subscribe(() => {
12605
- this.refreshCache();
12606
- });
12607
- }
12608
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12609
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, providedIn: 'root' }); }
12610
- }
12611
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, decorators: [{
12612
- type: Injectable,
12613
- args: [{
12614
- providedIn: 'root'
12615
- }]
12616
- }] });
12617
-
12618
12640
  var EmployeeMessagesEnum;
12619
12641
  (function (EmployeeMessagesEnum) {
12620
12642
  EmployeeMessagesEnum["ROLE_GRANTED"] = "Manager role granted to ";
@@ -14086,12 +14108,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
14086
14108
  }] });
14087
14109
 
14088
14110
  class ServicePaymentMethodService extends RestService$1 {
14089
- constructor(http, eventDispatcherService, environment, sseService) {
14111
+ constructor(http, eventDispatcherService, environment) {
14090
14112
  super(http, eventDispatcherService, environment);
14091
14113
  this.http = http;
14092
14114
  this.eventDispatcherService = eventDispatcherService;
14093
14115
  this.environment = environment;
14094
- this.sseService = sseService;
14095
14116
  this.endpointUri = 'service-payment-methods';
14096
14117
  this.collectionClass = Collection;
14097
14118
  this.modelClass = ServicePaymentMethod;
@@ -14125,7 +14146,7 @@ class ServicePaymentMethodService extends RestService$1 {
14125
14146
  this.handleResponse([plainToClass(ServicePaymentMethod, newPaymentMethod)], 'post');
14126
14147
  });
14127
14148
  }
14128
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ServicePaymentMethodService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: SseService }], target: i0.ɵɵFactoryTarget.Injectable }); }
14149
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ServicePaymentMethodService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
14129
14150
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ServicePaymentMethodService, providedIn: 'root' }); }
14130
14151
  }
14131
14152
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ServicePaymentMethodService, decorators: [{
@@ -14136,7 +14157,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
14136
14157
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
14137
14158
  type: Inject,
14138
14159
  args: ['environment']
14139
- }] }, { type: SseService }]; } });
14160
+ }] }]; } });
14140
14161
 
14141
14162
  /**
14142
14163
  * Service that handling banks logic
@@ -14174,12 +14195,10 @@ var SubscriptionMessagesEnum;
14174
14195
  * @TODO Alex refactor
14175
14196
  */
14176
14197
  class SubscriptionService extends RestService$1 {
14177
- constructor(http, eventDispatcherService, sseService, toastService, environment) {
14198
+ constructor(http, eventDispatcherService, environment) {
14178
14199
  super(http, eventDispatcherService, environment);
14179
14200
  this.http = http;
14180
14201
  this.eventDispatcherService = eventDispatcherService;
14181
- this.sseService = sseService;
14182
- this.toastService = toastService;
14183
14202
  this.environment = environment;
14184
14203
  this.isApiPlatform = true;
14185
14204
  this.endpointUri = 'service-subscriptions';
@@ -14254,7 +14273,7 @@ class SubscriptionService extends RestService$1 {
14254
14273
  }, 2000);
14255
14274
  });
14256
14275
  }
14257
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SubscriptionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: ToastService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
14276
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SubscriptionService, deps: [{ token: i1.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable }); }
14258
14277
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SubscriptionService, providedIn: 'root' }); }
14259
14278
  }
14260
14279
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SubscriptionService, decorators: [{
@@ -14262,7 +14281,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
14262
14281
  args: [{
14263
14282
  providedIn: 'root'
14264
14283
  }]
14265
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: ToastService }, { type: undefined, decorators: [{
14284
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
14266
14285
  type: Inject,
14267
14286
  args: ['environment']
14268
14287
  }] }]; } });
@@ -18191,7 +18210,7 @@ class AccountSetupService {
18191
18210
  batch.push(
18192
18211
  // Invite clients item is completed when firm has clients or firm has invited clients.
18193
18212
  this.setItemStatus(this.items.findBy('isInviteClients', true), combineLatest([this.clientMovementService.getActive(), this.clientInviteService.getFirmInvites()])
18194
- .pipe(map(([movements, invites]) => [...movements.toArray(), ...invites]))));
18213
+ .pipe(map(([movements, invites]) => [...movements.toArray(), ...invites.toArray()]))));
18195
18214
  return combineLatest(batch).pipe(map((items) => new AccountSetupItemCollection(items)));
18196
18215
  }
18197
18216
  /**