taxtank-core 0.32.0 → 0.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/esm2022/lib/collections/bank-account.collection.mjs +11 -4
  2. package/esm2022/lib/collections/subscription/service-subscription.collection.mjs +3 -3
  3. package/esm2022/lib/collections/vehicle/best-vehicle-logbook.collection.mjs +18 -14
  4. package/esm2022/lib/collections/vehicle/vehicle-logbook.collection.mjs +10 -5
  5. package/esm2022/lib/db/Models/firm/client-invite.mjs +3 -3
  6. package/esm2022/lib/db/Models/subscription/service-product.mjs +1 -1
  7. package/esm2022/lib/db/Models/subscription/service-subscription.mjs +1 -1
  8. package/esm2022/lib/services/account-setup/account-setup.service.mjs +2 -2
  9. package/esm2022/lib/services/http/bank/bank-connection/bank-connection.service.mjs +4 -6
  10. package/esm2022/lib/services/http/chat/chat.service.mjs +4 -5
  11. package/esm2022/lib/services/http/chat/message.service.mjs +4 -5
  12. package/esm2022/lib/services/http/firm/client-invite/client-invite-messages.enum.mjs +5 -2
  13. package/esm2022/lib/services/http/firm/client-invite/client-invite.service.mjs +56 -63
  14. package/esm2022/lib/services/http/firm/client-movement/client-movement.service.mjs +32 -32
  15. package/esm2022/lib/services/http/rest/rest.service.mjs +23 -2
  16. package/esm2022/lib/services/http/subscription/service-payment-method/service-payment-method.service.mjs +4 -5
  17. package/esm2022/lib/services/http/subscription/service-subscription/subscription.service.mjs +4 -7
  18. package/fesm2022/taxtank-core.mjs +518 -492
  19. package/fesm2022/taxtank-core.mjs.map +1 -1
  20. package/lib/collections/bank-account.collection.d.ts +4 -0
  21. package/lib/collections/vehicle/best-vehicle-logbook.collection.d.ts +2 -1
  22. package/lib/collections/vehicle/vehicle-logbook.collection.d.ts +3 -2
  23. package/lib/db/Models/firm/client-invite.d.ts +2 -2
  24. package/lib/db/Models/subscription/service-product.d.ts +2 -1
  25. package/lib/db/Models/subscription/service-subscription.d.ts +2 -0
  26. package/lib/services/http/bank/bank-connection/bank-connection.service.d.ts +1 -3
  27. package/lib/services/http/chat/chat.service.d.ts +2 -3
  28. package/lib/services/http/chat/message.service.d.ts +2 -3
  29. package/lib/services/http/firm/client-invite/client-invite-messages.enum.d.ts +5 -2
  30. package/lib/services/http/firm/client-invite/client-invite.service.d.ts +15 -14
  31. package/lib/services/http/firm/client-movement/client-movement.service.d.ts +19 -13
  32. package/lib/services/http/rest/rest.service.d.ts +13 -1
  33. package/lib/services/http/subscription/service-payment-method/service-payment-method.service.d.ts +2 -3
  34. package/lib/services/http/subscription/service-subscription/subscription.service.d.ts +2 -5
  35. package/package.json +1 -1
  36. package/lib/db/Models/address.d.ts.map +0 -1
  37. package/lib/db/Models/bank/bank-account-balance.d.ts.map +0 -1
  38. package/lib/db/Models/bank/bank-account-property.d.ts.map +0 -1
  39. package/lib/db/Models/bank/bank-account.d.ts.map +0 -1
  40. package/lib/db/Models/bank/bank-connection.d.ts.map +0 -1
  41. package/lib/db/Models/bank/bank-transaction-import.d.ts.map +0 -1
  42. package/lib/db/Models/bank/bank-transaction.d.ts.map +0 -1
  43. package/lib/db/Models/bank/bank.d.ts.map +0 -1
  44. package/lib/db/Models/bank/basiq-job.d.ts.map +0 -1
  45. package/lib/db/Models/chart-accounts/chart-accounts-depreciation.d.ts.map +0 -1
  46. package/lib/db/Models/chart-accounts/chart-accounts-heading.d.ts.map +0 -1
  47. package/lib/db/Models/chart-accounts/chart-accounts-meta-field.d.ts.map +0 -1
  48. package/lib/db/Models/chart-accounts/chart-accounts-value.d.ts.map +0 -1
  49. package/lib/db/Models/chart-accounts/chart-accounts.d.ts.map +0 -1
  50. package/lib/db/Models/client/client-details.d.ts.map +0 -1
  51. package/lib/db/Models/client/client-income-types.d.ts.map +0 -1
  52. package/lib/db/Models/client/occupation.d.ts.map +0 -1
  53. package/lib/db/Models/country.d.ts.map +0 -1
  54. package/lib/db/Models/depreciation/depreciation-capital-project.d.ts.map +0 -1
  55. package/lib/db/Models/depreciation/depreciation-forecast.d.ts.map +0 -1
  56. package/lib/db/Models/depreciation/depreciation.d.ts.map +0 -1
  57. package/lib/db/Models/document/document-base.d.ts.map +0 -1
  58. package/lib/db/Models/document/document-folder.d.ts.map +0 -1
  59. package/lib/db/Models/document/document.d.ts.map +0 -1
  60. package/lib/db/Models/document/property-document.d.ts.map +0 -1
  61. package/lib/db/Models/file.d.ts.map +0 -1
  62. package/lib/db/Models/firm/chat.d.ts.map +0 -1
  63. package/lib/db/Models/firm/client-invite.d.ts.map +0 -1
  64. package/lib/db/Models/firm/client-movement.d.ts.map +0 -1
  65. package/lib/db/Models/firm/employee-invite.d.ts.map +0 -1
  66. package/lib/db/Models/firm/firm-invite.d.ts.map +0 -1
  67. package/lib/db/Models/firm/firm.d.ts.map +0 -1
  68. package/lib/db/Models/firm/message-document.d.ts.map +0 -1
  69. package/lib/db/Models/firm/message.d.ts.map +0 -1
  70. package/lib/db/Models/holding/holding-sale.d.ts.map +0 -1
  71. package/lib/db/Models/incomeSource/income-source-forecast.d.ts.map +0 -1
  72. package/lib/db/Models/incomeSource/income-source-type.d.ts.map +0 -1
  73. package/lib/db/Models/incomeSource/income-source.d.ts.map +0 -1
  74. package/lib/db/Models/incomeSource/salary-forecast.d.ts.map +0 -1
  75. package/lib/db/Models/loan/borrowing-expense-loan.d.ts.map +0 -1
  76. package/lib/db/Models/loan/borrowing-expense.d.ts.map +0 -1
  77. package/lib/db/Models/loan/loan-payout.d.ts.map +0 -1
  78. package/lib/db/Models/loan/loan.d.ts.map +0 -1
  79. package/lib/db/Models/phone.d.ts.map +0 -1
  80. package/lib/db/Models/property/borrowing-report.d.ts.map +0 -1
  81. package/lib/db/Models/property/property-category-movement.d.ts.map +0 -1
  82. package/lib/db/Models/property/property-category.d.ts.map +0 -1
  83. package/lib/db/Models/property/property-forecast.d.ts.map +0 -1
  84. package/lib/db/Models/property/property-sale/property-sale-tax-exemption-meta-field.d.ts.map +0 -1
  85. package/lib/db/Models/property/property-sale/property-sale.d.ts.map +0 -1
  86. package/lib/db/Models/property/property-sale/tax-exemption-meta-field.d.ts.map +0 -1
  87. package/lib/db/Models/property/property-sale/tax-exemption.d.ts.map +0 -1
  88. package/lib/db/Models/property/property-share.d.ts.map +0 -1
  89. package/lib/db/Models/property/property-subscription.d.ts.map +0 -1
  90. package/lib/db/Models/property/property-valuation.d.ts.map +0 -1
  91. package/lib/db/Models/property/property.d.ts.map +0 -1
  92. package/lib/db/Models/service-notification.d.ts.map +0 -1
  93. package/lib/db/Models/sole/bas-report.d.ts.map +0 -1
  94. package/lib/db/Models/sole/sole-business-activity.d.ts.map +0 -1
  95. package/lib/db/Models/sole/sole-business-allocation.d.ts.map +0 -1
  96. package/lib/db/Models/sole/sole-business-loss-offset-rule.d.ts.map +0 -1
  97. package/lib/db/Models/sole/sole-business-loss.d.ts.map +0 -1
  98. package/lib/db/Models/sole/sole-business.d.ts.map +0 -1
  99. package/lib/db/Models/sole/sole-contact.d.ts.map +0 -1
  100. package/lib/db/Models/sole/sole-depreciation-method.d.ts.map +0 -1
  101. package/lib/db/Models/sole/sole-details.d.ts.map +0 -1
  102. package/lib/db/Models/sole/sole-forecast.d.ts.map +0 -1
  103. package/lib/db/Models/sole/sole-invoice-item.d.ts.map +0 -1
  104. package/lib/db/Models/sole/sole-invoice-template.d.ts.map +0 -1
  105. package/lib/db/Models/sole/sole-invoice.d.ts.map +0 -1
  106. package/lib/db/Models/spare/spare-document-category.d.ts.map +0 -1
  107. package/lib/db/Models/spare/spare-document.d.ts.map +0 -1
  108. package/lib/db/Models/subscription/service-payment-method.d.ts.map +0 -1
  109. package/lib/db/Models/subscription/service-payment.d.ts.map +0 -1
  110. package/lib/db/Models/subscription/service-price.d.ts.map +0 -1
  111. package/lib/db/Models/subscription/service-product.d.ts.map +0 -1
  112. package/lib/db/Models/subscription/service-subscription-item.d.ts.map +0 -1
  113. package/lib/db/Models/subscription/service-subscription.d.ts.map +0 -1
  114. package/lib/db/Models/tax-calculation.d.ts.map +0 -1
  115. package/lib/db/Models/tax-return/tax-return-category.d.ts.map +0 -1
  116. package/lib/db/Models/tax-return/tax-return-item.d.ts.map +0 -1
  117. package/lib/db/Models/tax-return/tax-return.d.ts.map +0 -1
  118. package/lib/db/Models/transaction/allocation-rule-condition.d.ts.map +0 -1
  119. package/lib/db/Models/transaction/allocation-rule-transaction-meta-field.d.ts.map +0 -1
  120. package/lib/db/Models/transaction/allocation-rule-transaction.d.ts.map +0 -1
  121. package/lib/db/Models/transaction/allocation-rule.d.ts.map +0 -1
  122. package/lib/db/Models/transaction/transaction-allocation.d.ts.map +0 -1
  123. package/lib/db/Models/transaction/transaction-meta-field.d.ts.map +0 -1
  124. package/lib/db/Models/transaction/transaction.d.ts.map +0 -1
  125. package/lib/db/Models/user/employee-details.d.ts.map +0 -1
  126. package/lib/db/Models/user/registration-invite.d.ts.map +0 -1
  127. package/lib/db/Models/user/user-event-setting.d.ts.map +0 -1
  128. package/lib/db/Models/user/user-event-type-category.d.ts.map +0 -1
  129. package/lib/db/Models/user/user-event-type.d.ts.map +0 -1
  130. package/lib/db/Models/user/user-event.d.ts.map +0 -1
  131. package/lib/db/Models/vehicle/vehicle-claim-details.d.ts.map +0 -1
  132. package/lib/db/Models/vehicle/vehicle-claim.d.ts.map +0 -1
  133. package/lib/db/Models/vehicle/vehicle-logbook.d.ts.map +0 -1
  134. package/lib/db/Models/vehicle/vehicle.d.ts.map +0 -1
  135. 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
  }
@@ -8839,9 +8849,16 @@ class BankAccountCollection extends Collection {
8839
8849
  getLVR(property) {
8840
8850
  return this.getPropertyBalanceAmount(property.id) / property.currentYearForecast.marketValue;
8841
8851
  }
8852
+ /**
8853
+ * @TODO Alex/Vik: maybe we should get it from jwtToken or think about some localStorageService?
8854
+ * get own bankAccounts active for current financial year
8855
+ */
8842
8856
  getOwn() {
8843
- // TODO Alex/Vik: maybe we should get it from jwtToken or think about some localStorageService?
8844
- return this.filter((bankAccount) => bankAccount.isOwner(+localStorage.getItem('userId')));
8857
+ return this.filter((bankAccount) => {
8858
+ const commencementDate = bankAccount.loan?.commencementDate;
8859
+ const endDate = new FinancialYear().endDate;
8860
+ return bankAccount.isOwner(+localStorage.getItem('userId')) && (!commencementDate || commencementDate <= endDate);
8861
+ });
8845
8862
  }
8846
8863
  getActiveLoanAccountsByProperties(ids) {
8847
8864
  return this.getActiveBankAccounts().getLoanAccounts().getByPropertiesIds(ids);
@@ -10394,89 +10411,37 @@ __decorate([
10394
10411
  Type(() => TaxReturnItem)
10395
10412
  ], TaxReturn.prototype, "taxReturnItems", void 0);
10396
10413
 
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
10414
  /**
10439
- * Convert single object or array into array
10415
+ * @TODO Alex (TT-1777): replace old logic with the new when all services ready
10416
+ * @TODO Alex (TT-1777): rename old logic and keep it for custom events
10440
10417
  */
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);
10418
+ class EventDispatcherService {
10419
+ constructor() {
10420
+ this.eventSubject = new Subject();
10421
+ this.eventSubject2 = new Subject();
10457
10422
  }
10458
10423
  /**
10459
- * never return cache directly to prevent update
10424
+ * subscription to specific event type
10460
10425
  */
10461
- getCache() {
10462
- return clone(this.cache);
10426
+ on(eventType) {
10427
+ return this.eventSubject.pipe(filter((event) => [].concat(eventType).includes(event.type)), map((event) => event.payload));
10463
10428
  }
10464
- /**
10465
- * never return cache directly to prevent update
10466
- */
10467
- getCacheFirst() {
10468
- return clone(this.cache?.first);
10429
+ on2(...names) {
10430
+ return this.eventSubject2.pipe(filter((event) => [].concat(names).includes(event.name)), map((event) => event.items));
10469
10431
  }
10470
10432
  /**
10471
- * @TODO vik any[] because of problems with base models extending abstractModel
10433
+ * deliver new event
10472
10434
  */
10473
- setCache(data) {
10474
- this.cache = this.createCollectionInstance(this.collectionClass, data.map((item) => this.createModelInstance(item)));
10435
+ dispatch(event) {
10436
+ this.eventSubject.next(event);
10475
10437
  }
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' }); }
10438
+ dispatch2(event) {
10439
+ this.eventSubject2.next(event);
10440
+ }
10441
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10442
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, providedIn: 'root' }); }
10478
10443
  }
10479
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, decorators: [{
10444
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: EventDispatcherService, decorators: [{
10480
10445
  type: Injectable,
10481
10446
  args: [{
10482
10447
  providedIn: 'root'
@@ -10533,43 +10498,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
10533
10498
  args: ['environment']
10534
10499
  }] }]; } });
10535
10500
 
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
10501
  const NAME_TOKEN = 'token';
10574
10502
  const NAME_REFRESH_TOKEN = 'refreshToken';
10575
10503
  class JwtService extends JwtHelperService {
@@ -10654,68 +10582,236 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
10654
10582
  args: ['environment']
10655
10583
  }] }]; } });
10656
10584
 
10585
+ // replace array element with the new one (only arrays of objects)
10586
+ function replace(array, item, matchField = 'id') {
10587
+ const index = array.findIndex((i) => i[matchField] === item[matchField]);
10588
+ array.splice(index, 1, item);
10589
+ }
10590
+
10591
+ // sort array of objects by field
10592
+ function sort(array, field = 'id', isDesc = true) {
10593
+ array.sort((a, b) => {
10594
+ if (a[field] > b[field]) {
10595
+ return !isDesc ? 1 : -1;
10596
+ }
10597
+ if (a[field] < b[field]) {
10598
+ return !isDesc ? -1 : 1;
10599
+ }
10600
+ return 0;
10601
+ });
10602
+ }
10603
+
10604
+ // sort array of objects by field
10605
+ function sortDeep(array, fieldsQueue = ['id'], isDesc = true) {
10606
+ array.sort((a, b) => {
10607
+ const aValue = getValue(a, fieldsQueue);
10608
+ const bValue = getValue(b, fieldsQueue);
10609
+ if (aValue > bValue) {
10610
+ return !isDesc ? 1 : -1;
10611
+ }
10612
+ if (aValue < bValue) {
10613
+ return !isDesc ? -1 : 1;
10614
+ }
10615
+ return 0;
10616
+ });
10617
+ }
10618
+ function getValue(obj, fields) {
10619
+ let value = obj;
10620
+ fields.forEach((field) => {
10621
+ value = value[field];
10622
+ });
10623
+ return value;
10624
+ }
10625
+
10657
10626
  /**
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
10627
+ * Convert single object or array into array
10663
10628
  */
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();
10684
- }
10685
- get apiUrl() {
10686
- return `${this.environment.apiV2}/${this.endpointUri}`;
10629
+ function toArray(data) {
10630
+ return Array.isArray(data) ? data : [data];
10631
+ }
10632
+
10633
+ class DataService {
10634
+ /**
10635
+ * @TODO use excludeExtraneousValues when all models refactored (exposed all needed properties)
10636
+ * Create new instance of class
10637
+ * @param model Single object or array from which will be created model instance(s)
10638
+ */
10639
+ createModelInstance(model) {
10640
+ // excludePrefixes - class-transformer option is using to ignore hydra fields
10641
+ return plainToClass(this.modelClass, model, { excludePrefixes: ['@'] });
10687
10642
  }
10688
- setCache(data, next = false) {
10689
- super.setCache(data);
10690
- if (next) {
10691
- this.cacheSubject.next(this.cache);
10692
- }
10643
+ createCollectionInstance(collectionClass, items) {
10644
+ return new collectionClass(items);
10693
10645
  }
10694
10646
  /**
10695
- * Refresh cache with actual backend data
10647
+ * never return cache directly to prevent update
10696
10648
  */
10697
- refreshCache() {
10698
- this.cache = undefined;
10699
- this.get();
10649
+ getCache() {
10650
+ return clone(this.cache);
10700
10651
  }
10701
10652
  /**
10702
- * Get data from backend and fill the cache
10653
+ * never return cache directly to prevent update
10703
10654
  */
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
- }));
10655
+ getCacheFirst() {
10656
+ return clone(this.cache?.first);
10717
10657
  }
10718
- get(path = this.apiUrl) {
10658
+ /**
10659
+ * @TODO vik any[] because of problems with base models extending abstractModel
10660
+ */
10661
+ setCache(data) {
10662
+ this.cache = this.createCollectionInstance(this.collectionClass, data.map((item) => this.createModelInstance(item)));
10663
+ }
10664
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10665
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, providedIn: 'root' }); }
10666
+ }
10667
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataService, decorators: [{
10668
+ type: Injectable,
10669
+ args: [{
10670
+ providedIn: 'root'
10671
+ }]
10672
+ }] });
10673
+
10674
+ /**
10675
+ * Common toast message class
10676
+ */
10677
+ class Toast {
10678
+ constructor() {
10679
+ this.duration = 3000;
10680
+ this.autoClose = true;
10681
+ }
10682
+ }
10683
+
10684
+ var ToastTypeEnum;
10685
+ (function (ToastTypeEnum) {
10686
+ ToastTypeEnum[ToastTypeEnum["INFO"] = 0] = "INFO";
10687
+ ToastTypeEnum[ToastTypeEnum["SUCCESS"] = 1] = "SUCCESS";
10688
+ ToastTypeEnum[ToastTypeEnum["WARNING"] = 2] = "WARNING";
10689
+ ToastTypeEnum[ToastTypeEnum["ERROR"] = 3] = "ERROR";
10690
+ })(ToastTypeEnum || (ToastTypeEnum = {}));
10691
+
10692
+ /**
10693
+ * popup notifications service (toast, snackbar).
10694
+ */
10695
+ class ToastService {
10696
+ constructor() {
10697
+ this.toast$ = new ReplaySubject(1);
10698
+ }
10699
+ get() {
10700
+ return this.toast$.asObservable();
10701
+ }
10702
+ add(toast) {
10703
+ // set date to prevent closing of equal toasts (extra case)
10704
+ toast.date = new Date(),
10705
+ this.toast$.next(toast);
10706
+ }
10707
+ success(message) {
10708
+ this.add(plainToClass(Toast, {
10709
+ type: ToastTypeEnum.SUCCESS,
10710
+ title: 'Success!',
10711
+ message,
10712
+ }));
10713
+ }
10714
+ warning(message) {
10715
+ this.add(plainToClass(Toast, {
10716
+ type: ToastTypeEnum.WARNING,
10717
+ title: 'Notification!',
10718
+ message,
10719
+ }));
10720
+ }
10721
+ error(message) {
10722
+ this.add(plainToClass(Toast, {
10723
+ type: ToastTypeEnum.ERROR,
10724
+ title: 'Error!',
10725
+ message,
10726
+ }));
10727
+ }
10728
+ info(message) {
10729
+ this.add(plainToClass(Toast, {
10730
+ type: ToastTypeEnum.INFO,
10731
+ title: 'Information',
10732
+ message,
10733
+ }));
10734
+ }
10735
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
10736
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, providedIn: 'root' }); }
10737
+ }
10738
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ToastService, decorators: [{
10739
+ type: Injectable,
10740
+ args: [{
10741
+ providedIn: 'root'
10742
+ }]
10743
+ }] });
10744
+
10745
+ /**
10746
+ * Abstract base service that implements common services functionality
10747
+ * and describe abstract methods/properties that have to be implemented in child services
10748
+ * Model - entity service is working with
10749
+ * BaseModel - base entity model that extends by Model
10750
+ * CollectionModel - entity collection class
10751
+ */
10752
+ let RestService$1 = class RestService extends DataService {
10753
+ constructor(http, eventDispatcherService, environment) {
10754
+ super();
10755
+ this.http = http;
10756
+ this.eventDispatcherService = eventDispatcherService;
10757
+ this.environment = environment;
10758
+ /**
10759
+ * Subject for service cache
10760
+ */
10761
+ this.cacheSubject = new ReplaySubject(1);
10762
+ /**
10763
+ * List of methods unavailable for current API
10764
+ * @TODO Alex: add and handle enabled methods too
10765
+ * @TODO Alex: disable batch by default
10766
+ */
10767
+ this.disabledMethods = [];
10768
+ this.mpService = inject(MixpanelService);
10769
+ this.sseService = inject(SseService);
10770
+ this.toastService = inject(ToastService);
10771
+ this.roles = [];
10772
+ /**
10773
+ * disable cache update by requests, update only by SSE events
10774
+ */
10775
+ this.disableCache = false;
10776
+ // @TODO Alex remove, bad idea to call empty method overrided in child (because it will be called with parent context)
10777
+ this.listenEvents();
10778
+ // @TODO Alex remove, bad idea to call empty method overrided in child (because it will be called with parent context)
10779
+ this.listenSSE();
10780
+ }
10781
+ get apiUrl() {
10782
+ return `${this.environment.apiV2}/${this.endpointUri}`;
10783
+ }
10784
+ setCache(data, next = false) {
10785
+ super.setCache(data);
10786
+ if (next) {
10787
+ this.cacheSubject.next(this.cache);
10788
+ }
10789
+ }
10790
+ /**
10791
+ * Refresh cache with actual backend data
10792
+ */
10793
+ refreshCache() {
10794
+ this.cache = undefined;
10795
+ this.get();
10796
+ }
10797
+ /**
10798
+ * Get data from backend and fill the cache
10799
+ */
10800
+ fetch(path = this.apiUrl) {
10801
+ this.handleAccessError('get');
10802
+ if (!this.hasRoles()) {
10803
+ this.setCache([], true);
10804
+ return this.cacheSubject.asObservable();
10805
+ }
10806
+ // Set cache as empty collection to avoid multiple requests before cache filled
10807
+ this.setCache([]);
10808
+ return this.http.get(path)
10809
+ .pipe(map((response) => this.isApiPlatform ? response['hydra:member'] : toArray(response)), map((response) => {
10810
+ this.setCache(response, true);
10811
+ return this.cache;
10812
+ }));
10813
+ }
10814
+ get(path = this.apiUrl) {
10719
10815
  if (!this.cache) {
10720
10816
  this.fetch(path).pipe(first$1()).subscribe();
10721
10817
  }
@@ -10725,6 +10821,9 @@ let RestService$1 = class RestService extends DataService {
10725
10821
  this.handleAccessError('get');
10726
10822
  return this.get().pipe(map((collection) => collection.first));
10727
10823
  }
10824
+ hasInCache(id) {
10825
+ return !!this.getCache().findBy('id', id);
10826
+ }
10728
10827
  getArray() {
10729
10828
  return this.get().pipe(map((collection) => collection.toArray()));
10730
10829
  }
@@ -10815,6 +10914,10 @@ let RestService$1 = class RestService extends DataService {
10815
10914
  }));
10816
10915
  }
10817
10916
  track(response, method, mpData, postfix = '') {
10917
+ // check if result exist, sometimes response may be empty (for example ClientInvite accept/reject/etc)
10918
+ if (!response[0]) {
10919
+ return;
10920
+ }
10818
10921
  // no other way to check interface
10819
10922
  if ('getMpData' in response[0]) {
10820
10923
  response.forEach((model) => {
@@ -10831,7 +10934,7 @@ let RestService$1 = class RestService extends DataService {
10831
10934
  */
10832
10935
  handleResponse(response, method, mpData) {
10833
10936
  this.track(response, method, mpData);
10834
- if (this.getCache()) {
10937
+ if (this.getCache() && !this.disableCache) {
10835
10938
  this.updateCache(response, method);
10836
10939
  }
10837
10940
  // dispatch event for interested services
@@ -10908,6 +11011,10 @@ let RestService$1 = class RestService extends DataService {
10908
11011
  * Method that call all listeners. Empty by default. Should be redefined by child services if required
10909
11012
  */
10910
11013
  listenEvents() { }
11014
+ /**
11015
+ * Listen SSE events
11016
+ */
11017
+ listenSSE() { }
10911
11018
  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
11019
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RestService, providedIn: 'root' }); }
10913
11020
  };
@@ -11014,89 +11121,17 @@ var BankConnectionMessagesEnum;
11014
11121
  BankConnectionMessagesEnum["TEMPORARY_UNAVAILABLE"] = "The bank is temporarily unavailable, please check back later";
11015
11122
  })(BankConnectionMessagesEnum || (BankConnectionMessagesEnum = {}));
11016
11123
 
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
11124
  /**
11089
11125
  * BankConnection means user account at specific bank (usually each user has only one at the same bank)
11090
11126
  * service handles BankConnection management
11091
11127
  */
11092
11128
  class BankConnectionService extends RestService$1 {
11093
- constructor(http, eventDispatcherService, sseService, environment, toastService) {
11129
+ constructor(http, eventDispatcherService, sseService, environment) {
11094
11130
  super(http, eventDispatcherService, environment);
11095
11131
  this.http = http;
11096
11132
  this.eventDispatcherService = eventDispatcherService;
11097
11133
  this.sseService = sseService;
11098
11134
  this.environment = environment;
11099
- this.toastService = toastService;
11100
11135
  this.isApiPlatform = true;
11101
11136
  this.modelClass = BankConnection;
11102
11137
  this.collectionClass = Collection;
@@ -11155,7 +11190,7 @@ class BankConnectionService extends RestService$1 {
11155
11190
  this.refreshCache();
11156
11191
  });
11157
11192
  }
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 }); }
11193
+ 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
11194
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BankConnectionService, providedIn: 'root' }); }
11160
11195
  }
11161
11196
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: BankConnectionService, decorators: [{
@@ -11166,7 +11201,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11166
11201
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
11167
11202
  type: Inject,
11168
11203
  args: ['environment']
11169
- }] }, { type: ToastService }]; } });
11204
+ }] }]; } });
11170
11205
 
11171
11206
  var UserEventTypeTypeEnum;
11172
11207
  (function (UserEventTypeTypeEnum) {
@@ -11569,12 +11604,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11569
11604
  * Service for work with chats
11570
11605
  */
11571
11606
  class ChatService extends RestService$1 {
11572
- constructor(http, eventDispatcherService, environment, sseService) {
11607
+ constructor(http, eventDispatcherService, environment) {
11573
11608
  super(http, eventDispatcherService, environment);
11574
11609
  this.http = http;
11575
11610
  this.eventDispatcherService = eventDispatcherService;
11576
11611
  this.environment = environment;
11577
- this.sseService = sseService;
11578
11612
  this.modelClass = Chat;
11579
11613
  this.collectionClass = ChatCollection;
11580
11614
  this.endpointUri = 'chats';
@@ -11630,7 +11664,7 @@ class ChatService extends RestService$1 {
11630
11664
  this.handleResponse([updatedChat], 'put');
11631
11665
  });
11632
11666
  }
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 }); }
11667
+ 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
11668
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChatService, providedIn: 'root' }); }
11635
11669
  }
11636
11670
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ChatService, decorators: [{
@@ -11641,18 +11675,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11641
11675
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11642
11676
  type: Inject,
11643
11677
  args: ['environment']
11644
- }] }, { type: SseService }]; } });
11678
+ }] }]; } });
11645
11679
 
11646
11680
  /**
11647
11681
  * Service for work with messages
11648
11682
  */
11649
11683
  class MessageService extends RestService$1 {
11650
- constructor(http, eventDispatcherService, environment, sseService) {
11684
+ constructor(http, eventDispatcherService, environment) {
11651
11685
  super(http, eventDispatcherService, environment);
11652
11686
  this.http = http;
11653
11687
  this.eventDispatcherService = eventDispatcherService;
11654
11688
  this.environment = environment;
11655
- this.sseService = sseService;
11656
11689
  this.modelClass = Message;
11657
11690
  this.collectionClass = MessageCollection;
11658
11691
  this.endpointUri = 'messages';
@@ -11689,7 +11722,7 @@ class MessageService extends RestService$1 {
11689
11722
  }
11690
11723
  });
11691
11724
  }
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 }); }
11725
+ 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
11726
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageService, providedIn: 'root' }); }
11694
11727
  }
11695
11728
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MessageService, decorators: [{
@@ -11700,7 +11733,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
11700
11733
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11701
11734
  type: Inject,
11702
11735
  args: ['environment']
11703
- }] }, { type: SseService }]; } });
11736
+ }] }]; } });
11704
11737
 
11705
11738
  /**
11706
11739
  * Service for work with Message Documents
@@ -12157,32 +12190,229 @@ class FileService extends RestService$1 {
12157
12190
  formData.append('file', file);
12158
12191
  return this.http.post(this.apiUrl, formData).pipe(map((fileBase) => plainToClass(AppFile, fileBase)));
12159
12192
  }
12160
- download(file) {
12161
- return this.http.get(`${this.apiUrl}/${file.id}/download`, { responseType: 'blob' });
12193
+ download(file) {
12194
+ return this.http.get(`${this.apiUrl}/${file.id}/download`, { responseType: 'blob' });
12195
+ }
12196
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12197
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, providedIn: 'root' }); }
12198
+ }
12199
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, decorators: [{
12200
+ type: Injectable,
12201
+ args: [{
12202
+ providedIn: 'root'
12203
+ }]
12204
+ }] });
12205
+
12206
+ class ClientIncomeTypesService extends RestService$1 {
12207
+ constructor() {
12208
+ super(...arguments);
12209
+ this.modelClass = ClientIncomeTypes;
12210
+ this.collectionClass = Collection;
12211
+ this.endpointUri = 'client-income-types';
12212
+ this.isApiPlatform = true;
12213
+ this.disabledMethods = ['postBatch', 'putBatch', 'delete', 'deleteBatch'];
12214
+ }
12215
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12216
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, providedIn: 'root' }); }
12217
+ }
12218
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, decorators: [{
12219
+ type: Injectable,
12220
+ args: [{
12221
+ providedIn: 'root'
12222
+ }]
12223
+ }] });
12224
+
12225
+ class ClientInviteService extends RestService$1 {
12226
+ constructor() {
12227
+ super(...arguments);
12228
+ this.endpointUri = 'clients/invites';
12229
+ this.collectionClass = ClientInviteCollection;
12230
+ this.modelClass = ClientInvite;
12231
+ }
12232
+ getFirmInvites() {
12233
+ return super.get(`${this.apiUrl}/all`);
12234
+ }
12235
+ /**
12236
+ * Get invite which employee is TaxTank Advisor
12237
+ * @TODO move to collection? but we need to inject enviroment
12238
+ */
12239
+ getTTAdvisor() {
12240
+ return this.get().pipe(map((invites) => invites.findBy('employee.email', this.environment.ttAdvisor)));
12241
+ }
12242
+ /**
12243
+ * Import clients from CSV file
12244
+ */
12245
+ import(file) {
12246
+ const formData = new FormData();
12247
+ formData.append('file', file);
12248
+ // cant use parent method because of different parameters
12249
+ return this.http.post(`${this.apiUrl}/import`, formData).pipe(map((clientInvite) => clientInvite));
12250
+ }
12251
+ /**
12252
+ * Accept client invitation from firm to user
12253
+ */
12254
+ accept(invite) {
12255
+ // cant use parent method because of custom specific handler
12256
+ return this.http.put(`${this.apiUrl}/${invite.id}/accept`, invite).pipe(map(() => {
12257
+ // @TODO remove when TaxReviewService refactored with the new rest and use there listenCSE instead
12258
+ // TaxReviewService is listening client invites acception. With the new rest we are using listenCSE method, but old rest does not have this method.
12259
+ // We need to refactor TaxReviewService with new rest first, then we can listenCSE and remove manual events
12260
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_INVITE_ACCEPTED, null));
12261
+ this.handleResponse([invite], 'delete');
12262
+ }));
12263
+ }
12264
+ /**
12265
+ * Reject client invitation from firm to user
12266
+ */
12267
+ reject(invite) {
12268
+ return super.put(invite, null, `${this.apiUrl}/${invite.id}/reject`);
12269
+ }
12270
+ /**
12271
+ * Resend invitation from firm to client
12272
+ */
12273
+ resend(invite) {
12274
+ // cant use parent method because of custom specific handler
12275
+ return this.http.post(`${this.apiUrl}/${invite.id}/resend`, null)
12276
+ .pipe(map((inviteBase) => plainToClass(ClientInvite, inviteBase)), map((resentInvite) => {
12277
+ this.handleResponse([resentInvite], 'put');
12278
+ return resentInvite;
12279
+ }));
12280
+ }
12281
+ /**
12282
+ * Send invitation from client to firm
12283
+ */
12284
+ inviteFirmByUser(invite) {
12285
+ return super.post(invite, null, `${this.environment.apiV2}/firms/invite`)
12286
+ .pipe(catchError((error) => {
12287
+ if (error.error.email) {
12288
+ this.toastService.error(error.error.email[0]);
12289
+ }
12290
+ else {
12291
+ this.toastService.error(error.error);
12292
+ }
12293
+ return throwError(error);
12294
+ }));
12295
+ }
12296
+ /**
12297
+ * Listem clientInvites db changes via mercure to update cache
12298
+ * @TODO make it universal and move to parent
12299
+ */
12300
+ listenSSE() {
12301
+ this.sseService.on('clientInvites')
12302
+ .pipe(map((clientInvite) => plainToClass(ClientInvite, clientInvite)))
12303
+ .subscribe((clientInvite) => {
12304
+ // we got empty body when item deleted so we should get id from Api Platform data (@id)
12305
+ const id = clientInvite.id ?? +last(clientInvite['@id'].split('/'));
12306
+ switch (true) {
12307
+ case !clientInvite.id:
12308
+ this.updateCache([merge(clientInvite, { id })], 'delete');
12309
+ break;
12310
+ case this.hasInCache(id):
12311
+ this.updateCache([clientInvite], 'put');
12312
+ break;
12313
+ case !this.hasInCache(id):
12314
+ this.updateCache([clientInvite], 'post');
12315
+ }
12316
+ });
12162
12317
  }
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' }); }
12318
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12319
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, providedIn: 'root' }); }
12165
12320
  }
12166
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: FileService, decorators: [{
12321
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientInviteService, decorators: [{
12167
12322
  type: Injectable,
12168
12323
  args: [{
12169
12324
  providedIn: 'root'
12170
12325
  }]
12171
12326
  }] });
12172
12327
 
12173
- class ClientIncomeTypesService extends RestService$1 {
12328
+ var ClientInviteMessages;
12329
+ (function (ClientInviteMessages) {
12330
+ ClientInviteMessages["TT_ADVISOR_INVITED"] = "You have Invited TaxTank Support successfully";
12331
+ ClientInviteMessages["TT_INVITE_ACCEPT"] = "You successfully accepted the invitation";
12332
+ ClientInviteMessages["REVOKE_TT_ADVISOR_CONFIRM"] = "Are you sure you want to revoke access?";
12333
+ ClientInviteMessages["TT_ADVISOR_REVOKED"] = "Access revoked";
12334
+ ClientInviteMessages["SEND_INVITE_MESSAGES_TITLE"] = "TaxTank support is here to help";
12335
+ ClientInviteMessages["SEND_INVITE_MESSAGES_DESCRIPTION"] = "Before inviting TaxTank support be sure to check out our help articles and message our support team.";
12336
+ ClientInviteMessages["TT_ACCOUNTANT_INVITED"] = "Accountant invitation has been sent successfully";
12337
+ 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.";
12338
+ ClientInviteMessages["CONFIRM_REJECT"] = "Are you sure you want to reject this invitation?";
12339
+ ClientInviteMessages["REJECTED"] = "Invitation rejected";
12340
+ ClientInviteMessages["ACCEPTED"] = "Client invitation accepted";
12341
+ })(ClientInviteMessages || (ClientInviteMessages = {}));
12342
+
12343
+ class ClientMovementService extends RestService$1 {
12174
12344
  constructor() {
12175
12345
  super(...arguments);
12176
- this.modelClass = ClientIncomeTypes;
12177
- this.collectionClass = Collection;
12178
- this.endpointUri = 'client-income-types';
12346
+ this.endpointUri = 'client-movements';
12347
+ this.collectionClass = ClientMovementCollection;
12348
+ this.modelClass = ClientMovement;
12179
12349
  this.isApiPlatform = true;
12180
- this.disabledMethods = ['postBatch', 'putBatch', 'delete', 'deleteBatch'];
12350
+ this.disabledMethods = ['postBatch', 'delete', 'deleteBatch'];
12181
12351
  }
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' }); }
12352
+ listenEvents() {
12353
+ // @TODO handle with mercure
12354
+ this.listenCSE(ClientInvite, ['post', 'put', 'delete'], this.refreshCache);
12355
+ }
12356
+ getActive() {
12357
+ return this.get().pipe(map((clientMovements) => clientMovements.active));
12358
+ }
12359
+ getTTAdvisor() {
12360
+ return this.getActive()
12361
+ .pipe(map((movements) => movements.findBy('employee.email', this.environment.ttAdvisor) || null));
12362
+ }
12363
+ getActiveByFirmType(type) {
12364
+ return this.getActive().pipe(map((clientMovements) => clientMovements.getByFirmType(type)));
12365
+ }
12366
+ /**
12367
+ * Method is using for transfer client between employees.
12368
+ * On backend we close passed movement and create a new one instead
12369
+ */
12370
+ put(movement) {
12371
+ // extend base 'add' method and pass into it movement without id
12372
+ return super.post(plainToClass(ClientMovement, Object.assign({}, movement, { id: null }))).pipe(map((updatedMovement) => {
12373
+ // remove provided movement from cache
12374
+ this.cache = this.cache.filter((item) => item.id !== movement.id);
12375
+ this.updateCache([updatedMovement], 'post');
12376
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_TRANSFER_TO_OTHER_EMPLOYEE, [updatedMovement.client]));
12377
+ return updatedMovement;
12378
+ }));
12379
+ }
12380
+ /**
12381
+ * There is no actually direct updating of client movement, but we are using this method for transfer clients between employees
12382
+ */
12383
+ putBatch(clientMovements) {
12384
+ const batch = clientMovements.map((clientMovement) => this.put(clientMovement));
12385
+ return forkJoin(batch);
12386
+ }
12387
+ /**
12388
+ * Reject current firm
12389
+ */
12390
+ close(clientMovement) {
12391
+ clientMovement.dateTo = new Date();
12392
+ // cant use parent method because of custom specific handler
12393
+ return this.http.put(`${this.environment.apiV2}/client-movements/${clientMovement.id}/close`, clientMovement)
12394
+ .pipe(map(() => {
12395
+ // @TODO remove when TaxReviewService refactored with the new rest and use there listenCSE instead
12396
+ this.eventDispatcherService.dispatch(new AppEvent(AppEventTypeEnum.CLIENT_MOVEMENT_CLOSED, null));
12397
+ this.cache = this.cache.filter((movement) => movement.id !== clientMovement.id);
12398
+ this.updateCache([clientMovement], 'delete');
12399
+ }));
12400
+ }
12401
+ /**
12402
+ * Listem clientMovements db changes via mercure to update cache
12403
+ * @TODO make it universal and move to parent
12404
+ */
12405
+ listenSSE() {
12406
+ this.sseService.on('clientMovements')
12407
+ .pipe(map((clientMovement) => plainToClass(ClientMovement, clientMovement)))
12408
+ .subscribe((clientMovement) => {
12409
+ this.hasInCache(clientMovement.id) ? this.updateCache([clientMovement], 'put') : this.updateCache([clientMovement], 'post');
12410
+ });
12411
+ }
12412
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
12413
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, providedIn: 'root' }); }
12184
12414
  }
12185
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientIncomeTypesService, decorators: [{
12415
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ClientMovementService, decorators: [{
12186
12416
  type: Injectable,
12187
12417
  args: [{
12188
12418
  providedIn: 'root'
@@ -12414,207 +12644,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
12414
12644
  args: ['environment']
12415
12645
  }] }, { type: ToastService }]; } });
12416
12646
 
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
12647
  var EmployeeMessagesEnum;
12619
12648
  (function (EmployeeMessagesEnum) {
12620
12649
  EmployeeMessagesEnum["ROLE_GRANTED"] = "Manager role granted to ";
@@ -14086,12 +14115,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
14086
14115
  }] });
14087
14116
 
14088
14117
  class ServicePaymentMethodService extends RestService$1 {
14089
- constructor(http, eventDispatcherService, environment, sseService) {
14118
+ constructor(http, eventDispatcherService, environment) {
14090
14119
  super(http, eventDispatcherService, environment);
14091
14120
  this.http = http;
14092
14121
  this.eventDispatcherService = eventDispatcherService;
14093
14122
  this.environment = environment;
14094
- this.sseService = sseService;
14095
14123
  this.endpointUri = 'service-payment-methods';
14096
14124
  this.collectionClass = Collection;
14097
14125
  this.modelClass = ServicePaymentMethod;
@@ -14125,7 +14153,7 @@ class ServicePaymentMethodService extends RestService$1 {
14125
14153
  this.handleResponse([plainToClass(ServicePaymentMethod, newPaymentMethod)], 'post');
14126
14154
  });
14127
14155
  }
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 }); }
14156
+ 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
14157
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ServicePaymentMethodService, providedIn: 'root' }); }
14130
14158
  }
14131
14159
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ServicePaymentMethodService, decorators: [{
@@ -14136,7 +14164,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
14136
14164
  }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
14137
14165
  type: Inject,
14138
14166
  args: ['environment']
14139
- }] }, { type: SseService }]; } });
14167
+ }] }]; } });
14140
14168
 
14141
14169
  /**
14142
14170
  * Service that handling banks logic
@@ -14174,12 +14202,10 @@ var SubscriptionMessagesEnum;
14174
14202
  * @TODO Alex refactor
14175
14203
  */
14176
14204
  class SubscriptionService extends RestService$1 {
14177
- constructor(http, eventDispatcherService, sseService, toastService, environment) {
14205
+ constructor(http, eventDispatcherService, environment) {
14178
14206
  super(http, eventDispatcherService, environment);
14179
14207
  this.http = http;
14180
14208
  this.eventDispatcherService = eventDispatcherService;
14181
- this.sseService = sseService;
14182
- this.toastService = toastService;
14183
14209
  this.environment = environment;
14184
14210
  this.isApiPlatform = true;
14185
14211
  this.endpointUri = 'service-subscriptions';
@@ -14254,7 +14280,7 @@ class SubscriptionService extends RestService$1 {
14254
14280
  }, 2000);
14255
14281
  });
14256
14282
  }
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 }); }
14283
+ 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
14284
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SubscriptionService, providedIn: 'root' }); }
14259
14285
  }
14260
14286
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SubscriptionService, decorators: [{
@@ -14262,7 +14288,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
14262
14288
  args: [{
14263
14289
  providedIn: 'root'
14264
14290
  }]
14265
- }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: ToastService }, { type: undefined, decorators: [{
14291
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
14266
14292
  type: Inject,
14267
14293
  args: ['environment']
14268
14294
  }] }]; } });
@@ -18191,7 +18217,7 @@ class AccountSetupService {
18191
18217
  batch.push(
18192
18218
  // Invite clients item is completed when firm has clients or firm has invited clients.
18193
18219
  this.setItemStatus(this.items.findBy('isInviteClients', true), combineLatest([this.clientMovementService.getActive(), this.clientInviteService.getFirmInvites()])
18194
- .pipe(map(([movements, invites]) => [...movements.toArray(), ...invites]))));
18220
+ .pipe(map(([movements, invites]) => [...movements.toArray(), ...invites.toArray()]))));
18195
18221
  return combineLatest(batch).pipe(map((items) => new AccountSetupItemCollection(items)));
18196
18222
  }
18197
18223
  /**