taxtank-core 0.19.2 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/bundles/taxtank-core.umd.js +646 -399
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/collection.js +6 -3
  4. package/esm2015/lib/db/Enums/bank-popular.enum.js +14 -0
  5. package/esm2015/lib/forms/abstract.form.js +11 -4
  6. package/esm2015/lib/forms/bank/bank-account/bank-account-add-manual.form.js +75 -0
  7. package/esm2015/lib/forms/bank/bank-account/bank-account-import.form.js +43 -0
  8. package/esm2015/lib/forms/bank/bank-account/bank-account-loan.form.js +23 -0
  9. package/esm2015/lib/forms/bank/bank-account/bank-account-properties.form.js +36 -0
  10. package/esm2015/lib/forms/bank/bank-account/bank-accounts-import.form.js +50 -0
  11. package/esm2015/lib/forms/index.js +6 -7
  12. package/esm2015/lib/forms/register/register-client.form.js +1 -2
  13. package/esm2015/lib/forms/report/my-tax/my-tax-income-statements.form.js +3 -3
  14. package/esm2015/lib/forms/user/password.form.js +3 -2
  15. package/esm2015/lib/forms/user/reset-password.form.js +2 -1
  16. package/esm2015/lib/interceptors/jwt-interceptor.js +6 -1
  17. package/esm2015/lib/interfaces/auth-tokens.interface.js +2 -0
  18. package/esm2015/lib/models/bank/bank.js +7 -2
  19. package/esm2015/lib/models/dictionary/dictionary.js +35 -0
  20. package/esm2015/lib/models/endpoint/endpoints.const.js +4 -2
  21. package/esm2015/lib/services/auth/auth.service.js +2 -2
  22. package/esm2015/lib/services/http/bank/bank-account/bank-account.service.js +7 -1
  23. package/esm2015/lib/services/http/bank/bank-connection/bank-connection.service.js +15 -45
  24. package/esm2015/lib/services/http/bank/bank.service.js +8 -1
  25. package/esm2015/lib/services/http/bank/basiq/basiq.service.js +52 -14
  26. package/esm2015/lib/services/http/facebook/facebook-auth-options.interface.js +2 -0
  27. package/esm2015/lib/services/http/facebook/facebook-auth-response.interface.js +2 -0
  28. package/esm2015/lib/services/http/facebook/facebook-status-response.interface.js +2 -0
  29. package/esm2015/lib/services/http/facebook/facebook.service.js +90 -0
  30. package/esm2015/lib/services/http/user/user.service.js +4 -1
  31. package/esm2015/lib/validators/at-least-one-enabled.validator.js +11 -0
  32. package/esm2015/lib/validators/autocomplete.validator.js +10 -0
  33. package/esm2015/lib/validators/index.js +2 -3
  34. package/esm2015/public-api.js +3 -2
  35. package/fesm2015/taxtank-core.js +537 -308
  36. package/fesm2015/taxtank-core.js.map +1 -1
  37. package/lib/collections/collection.d.ts +2 -1
  38. package/lib/db/Enums/bank-popular.enum.d.ts +12 -0
  39. package/lib/forms/abstract.form.d.ts +5 -3
  40. package/lib/forms/bank/bank-account/bank-account-add-manual.form.d.ts +25 -0
  41. package/lib/forms/bank/bank-account/bank-account-import.form.d.ts +15 -0
  42. package/lib/forms/bank/bank-account/bank-account-loan.form.d.ts +8 -0
  43. package/lib/forms/bank/bank-account/bank-account-properties.form.d.ts +11 -0
  44. package/lib/forms/bank/bank-account/bank-accounts-import.form.d.ts +12 -0
  45. package/lib/forms/index.d.ts +5 -6
  46. package/lib/interfaces/auth-tokens.interface.d.ts +7 -0
  47. package/lib/models/bank/bank.d.ts +1 -0
  48. package/lib/models/dictionary/dictionary.d.ts +12 -0
  49. package/lib/services/auth/auth.service.d.ts +2 -1
  50. package/lib/services/http/bank/bank-account/bank-account.service.d.ts +3 -0
  51. package/lib/services/http/bank/bank-connection/bank-connection.service.d.ts +0 -8
  52. package/lib/services/http/bank/bank.service.d.ts +2 -0
  53. package/lib/services/http/bank/basiq/basiq.service.d.ts +12 -3
  54. package/lib/services/http/facebook/facebook-auth-options.interface.d.ts +11 -0
  55. package/lib/services/http/facebook/facebook-auth-response.interface.d.ts +11 -0
  56. package/lib/services/http/facebook/facebook-status-response.interface.d.ts +9 -0
  57. package/lib/services/http/facebook/facebook.service.d.ts +38 -0
  58. package/lib/services/http/user/user.service.d.ts +1 -0
  59. package/lib/validators/at-least-one-enabled.validator.d.ts +5 -0
  60. package/lib/validators/{require-autocomplete.d.ts → autocomplete.validator.d.ts} +2 -1
  61. package/lib/validators/index.d.ts +1 -2
  62. package/package.json +1 -1
  63. package/public-api.d.ts +2 -1
  64. package/esm2015/lib/collections/bank.collection.js +0 -15
  65. package/esm2015/lib/forms/bank/bank-account-add-manual.form.js +0 -19
  66. package/esm2015/lib/forms/bank/bank-account-loan.form.js +0 -20
  67. package/esm2015/lib/forms/bank/bank-account-migrate.form.js +0 -15
  68. package/esm2015/lib/forms/bank/bank-account-properties.form.js +0 -15
  69. package/esm2015/lib/forms/bank/bank-account-property.form.js +0 -13
  70. package/esm2015/lib/forms/bank/bank-account.form.js +0 -66
  71. package/esm2015/lib/validators/require-autocomplete.js +0 -14
  72. package/esm2015/lib/validators/require-select.validator.js +0 -15
  73. package/lib/collections/bank.collection.d.ts +0 -7
  74. package/lib/forms/bank/bank-account-add-manual.form.d.ts +0 -10
  75. package/lib/forms/bank/bank-account-loan.form.d.ts +0 -5
  76. package/lib/forms/bank/bank-account-migrate.form.d.ts +0 -9
  77. package/lib/forms/bank/bank-account-properties.form.d.ts +0 -8
  78. package/lib/forms/bank/bank-account-property.form.d.ts +0 -5
  79. package/lib/forms/bank/bank-account.form.d.ts +0 -28
  80. package/lib/validators/require-select.validator.d.ts +0 -5
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/last'), require('moment'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('lodash/cloneDeep'), require('lodash/compact'), require('lodash/uniqBy'), require('lodash/concat'), require('moment-range'), require('@angular/forms'), require('lodash/fromPairs'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
- typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/last', 'moment', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'lodash/cloneDeep', 'lodash/compact', 'lodash/uniqBy', 'lodash/concat', 'moment-range', '@angular/forms', 'lodash/fromPairs', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'html2pdf.js', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.last, global.moment, global.flatten, global.hasIn, global.first, global.cloneDeep$1, global.compact, global.uniqBy, global.concat, global.momentRange, global.ng.forms, global.fromPairs, global._, global.eventsource_min_js, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
- })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, moment, flatten, hasIn, first, cloneDeep$1, compact, uniqBy, concat, momentRange, forms, fromPairs, _, eventsource_min_js, i1$2, clone, html2pdf, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('class-transformer'), require('@auth0/angular-jwt'), require('lodash/get'), require('lodash/last'), require('moment'), require('lodash/flatten'), require('lodash/hasIn'), require('lodash/first'), require('lodash/uniqBy'), require('lodash/concat'), require('rxjs/internal/observable/throwError'), require('lodash/cloneDeep'), require('lodash/compact'), require('moment-range'), require('@angular/forms'), require('lodash/fromPairs'), require('lodash'), require('event-source-polyfill/src/eventsource.min.js'), require('@angular/router'), require('lodash/clone'), require('html2pdf.js'), require('jspdf'), require('jspdf-autotable'), require('@stripe/stripe-js'), require('xlsx'), require('file-saver')) :
3
+ typeof define === 'function' && define.amd ? define('taxtank-core', ['exports', '@angular/core', '@angular/common', '@angular/common/http', 'rxjs', 'rxjs/operators', 'class-transformer', '@auth0/angular-jwt', 'lodash/get', 'lodash/last', 'moment', 'lodash/flatten', 'lodash/hasIn', 'lodash/first', 'lodash/uniqBy', 'lodash/concat', 'rxjs/internal/observable/throwError', 'lodash/cloneDeep', 'lodash/compact', 'moment-range', '@angular/forms', 'lodash/fromPairs', 'lodash', 'event-source-polyfill/src/eventsource.min.js', '@angular/router', 'lodash/clone', 'html2pdf.js', 'jspdf', 'jspdf-autotable', '@stripe/stripe-js', 'xlsx', 'file-saver'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["taxtank-core"] = {}, global.ng.core, global.ng.common, global.ng.common.http, global.rxjs, global.rxjs.operators, global.classTransformer, global.angularJwt, global.get, global.last, global.moment, global.flatten, global.hasIn, global.first, global.uniqBy, global.concat, global.rxjs["internal/observable/throwError"], global.cloneDeep$1, global.compact, global.momentRange, global.ng.forms, global.fromPairs, global._, global.eventsource_min_js, global.ng.router, global.clone, global.html2pdf, global.jsPDF, global.autoTable, global.stripeJs, global.xlsx, global.FileSaver));
5
+ })(this, (function (exports, i0, i1$1, i1, rxjs, operators, classTransformer, angularJwt, get, last, moment, flatten, hasIn, first, uniqBy, concat, throwError, cloneDeep$1, compact, momentRange, forms, fromPairs, _, eventsource_min_js, i1$2, clone, html2pdf, jsPDF, autoTable, stripeJs, xlsx, FileSaver) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -33,10 +33,10 @@
33
33
  var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
34
34
  var hasIn__default = /*#__PURE__*/_interopDefaultLegacy(hasIn);
35
35
  var first__default = /*#__PURE__*/_interopDefaultLegacy(first);
36
- var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep$1);
37
- var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
38
36
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
39
37
  var concat__default = /*#__PURE__*/_interopDefaultLegacy(concat);
38
+ var cloneDeep__default = /*#__PURE__*/_interopDefaultLegacy(cloneDeep$1);
39
+ var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
40
40
  var fromPairs__default = /*#__PURE__*/_interopDefaultLegacy(fromPairs);
41
41
  var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
42
42
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
@@ -647,7 +647,7 @@
647
647
  };
648
648
  AuthService.prototype.login = function (username, password) {
649
649
  var _this = this;
650
- return this.http.post(this.environment.apiV2 + "/login_check", { username: username, password: password }).pipe(operators.map(function (response) {
650
+ return this.http.post(this.environment.apiV2 + "/login", { username: username, password: password }).pipe(operators.map(function (response) {
651
651
  _this.setAuth(response);
652
652
  return response;
653
653
  }));
@@ -757,6 +757,11 @@
757
757
  };
758
758
  JwtInterceptor.prototype.handle401Error = function (req, next, err) {
759
759
  var _this = this;
760
+ var _a;
761
+ // skip 401 errors not from JWT (basiq login case or other)
762
+ if (!((_a = err.error.message) === null || _a === void 0 ? void 0 : _a.includes('JWT Token'))) {
763
+ return rxjs.throwError(err);
764
+ }
760
765
  if (req.url.includes('token/refresh') || req.url.includes('login')) {
761
766
  if (req.url.includes('token/refresh')) {
762
767
  this.authService.logoutFront();
@@ -964,6 +969,7 @@
964
969
  EMPLOYEES_INVITE_POST: new Endpoint('POST', '\\/employees\\/\\invites'),
965
970
  EMPLOYEES_INVITES_REJECT_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\reject'),
966
971
  EMPLOYEES_INVITES_RESEND_POST: new Endpoint('POST', '\\/employees\\/\\invites\\/\\d+\\/\\resend'),
972
+ FACEBOOK_LOGIN_POST: new Endpoint('POST', '\\/users\\/authentication\\/facebook'),
967
973
  FIRM_GET: new Endpoint('GET', '\\/firms'),
968
974
  FIRM_CURRENT_GET: new Endpoint('GET', '\\/firms\\/current'),
969
975
  FIRM_CURRENT_PUT: new Endpoint('PUT', '\\/firms\\/current\.\*'),
@@ -991,7 +997,7 @@
991
997
  LOANS_PAYOUT_PUT: new Endpoint('PUT', '\\/loans\\/\\d+\\/payout\\/\\d+'),
992
998
  LOANS_PAYOUT_DELETE: new Endpoint('DELETE', '\\/loans\\/\\d+\\/payout\\/\\d+'),
993
999
  LOANS_CALCULATION_POST: new Endpoint('POST', '\\/bank-accounts\\/loans\\/calculation'),
994
- LOGIN_CHECK_POST: new Endpoint('POST', '\\/login_check'),
1000
+ LOGIN_POST: new Endpoint('POST', '\\/login'),
995
1001
  NOTIFICATIONS_GET: new Endpoint('GET', '\\/service-notifications'),
996
1002
  OCCUPATIONS_GET: new Endpoint('GET', '\\/occupations'),
997
1003
  PROPERTIES_GET: new Endpoint('GET', '\\/properties'),
@@ -1045,6 +1051,7 @@
1045
1051
  TRANSACTIONS_ALLOCATIONS_POST: new Endpoint('POST', '\\/transactions-allocations'),
1046
1052
  TRANSACTIONS_ALLOCATIONS_DELETE: new Endpoint('DELETE', '\\/transactions-allocations\\/\\d+'),
1047
1053
  USER_CONFIRMATION_POST: new Endpoint('POST', '\\/users\\/confirmation'),
1054
+ USER_CONFIRMATION_RESEND_POST: new Endpoint('POST', '\\/users\\/confirmation\\/resend'),
1048
1055
  USER_CURRENT_GET: new Endpoint('GET', '\\/users\\/current'),
1049
1056
  USER_CURRENT_PASSWORD_PUT: new Endpoint('PUT', '\\/users\\/current\\/password\.\*'),
1050
1057
  USER_EVENT_SETTINGS_GET: new Endpoint('GET', '\\/user-event-settings'),
@@ -2792,6 +2799,9 @@
2792
2799
  Collection.prototype.getIds = function () {
2793
2800
  return this.items.map(function (item) { return item['id']; });
2794
2801
  };
2802
+ Collection.prototype.mapBy = function (path) {
2803
+ return this.items.map(function (item) { return get__default["default"](item, path); });
2804
+ };
2795
2805
  Collection.prototype.sortBy = function (field, isDesc) {
2796
2806
  if (field === void 0) { field = 'id'; }
2797
2807
  if (isDesc === void 0) { isDesc = true; }
@@ -2854,8 +2864,8 @@
2854
2864
  Collection.prototype.remove = function (items) {
2855
2865
  return this.filter(function (model) { return !items.map(function (item) { return item.id; }).includes(model.id); });
2856
2866
  };
2857
- Collection.prototype.removeBy = function (path, value) {
2858
- return this.filter(function (item) { return get__default["default"](item, path) !== value; });
2867
+ Collection.prototype.removeBy = function (path, values) {
2868
+ return this.filter(function (item) { return !(Array.isArray(values) ? values : [values]).includes(get__default["default"](item, path)); });
2859
2869
  };
2860
2870
  return Collection;
2861
2871
  }());
@@ -3225,6 +3235,20 @@
3225
3235
  return Bank;
3226
3236
  }(AbstractModel));
3227
3237
 
3238
+ var BankPopularEnum;
3239
+ (function (BankPopularEnum) {
3240
+ BankPopularEnum["BANKWEST"] = "Bank of Western Australia trading as BankWest";
3241
+ BankPopularEnum["ANZ"] = "Australia and New Zealand Banking Group Limited";
3242
+ BankPopularEnum["CBA"] = "Commonwealth Bank Australia";
3243
+ BankPopularEnum["WESTPAC"] = "Westpac Banking Corporation";
3244
+ BankPopularEnum["BENDIGO"] = "Bendigo and Adelaide Bank Limited";
3245
+ BankPopularEnum["ING_DIRECT"] = "ING Bank (Australia) Limited (trading as ING Direct)";
3246
+ BankPopularEnum["ST_GEORGE"] = "St. George Bank (a subsidiary of Westpac)";
3247
+ BankPopularEnum["SUNCORP"] = "Suncorp-Metway Limited";
3248
+ BankPopularEnum["CITIBANK"] = "Citibank";
3249
+ BankPopularEnum["BOQ"] = "Bank of Queensland Limited";
3250
+ })(BankPopularEnum || (BankPopularEnum = {}));
3251
+
3228
3252
  var Bank = /** @class */ (function (_super) {
3229
3253
  __extends(Bank, _super);
3230
3254
  function Bank() {
@@ -3247,6 +3271,13 @@
3247
3271
  return value ? value.replace(' ', '%20') : null;
3248
3272
  })
3249
3273
  ], Bank.prototype, "logo", void 0);
3274
+ __decorate([
3275
+ classTransformer.Transform(function (_a) {
3276
+ var obj = _a.obj;
3277
+ return Object.values(BankPopularEnum).includes(obj.name);
3278
+ }),
3279
+ classTransformer.Expose()
3280
+ ], Bank.prototype, "isPopular", void 0);
3250
3281
 
3251
3282
  exports.BankConnectionStatusEnum = void 0;
3252
3283
  (function (BankConnectionStatusEnum) {
@@ -3407,16 +3438,151 @@
3407
3438
  classTransformer.Type(function () { return BankConnection; })
3408
3439
  ], BankAccount.prototype, "bankConnection", void 0);
3409
3440
 
3441
+ var TYPE_LOAN = [
3442
+ exports.BankAccountTypeEnum.MORTGAGE,
3443
+ exports.BankAccountTypeEnum.CREDIT_CARD,
3444
+ exports.BankAccountTypeEnum.LOAN
3445
+ ];
3446
+
3410
3447
  /**
3411
- * any event happened in the app, which needs to be handled somehow (distributed to other part of the app)
3448
+ * Collection of bank accounts.
3412
3449
  */
3413
- var AppEvent = /** @class */ (function () {
3414
- function AppEvent(type, payload) {
3415
- this.type = type;
3416
- this.payload = payload;
3450
+ var BankAccountCollection = /** @class */ (function (_super) {
3451
+ __extends(BankAccountCollection, _super);
3452
+ function BankAccountCollection() {
3453
+ return _super !== null && _super.apply(this, arguments) || this;
3417
3454
  }
3418
- return AppEvent;
3419
- }());
3455
+ /**
3456
+ * get list of bank accounts with passed types
3457
+ */
3458
+ BankAccountCollection.prototype.getByType = function (types, isExclude) {
3459
+ if (isExclude === void 0) { isExclude = false; }
3460
+ // get types always as array (if only one passed)
3461
+ var typesArray = concat__default["default"](types);
3462
+ return this.items.filter(function (bankAccount) {
3463
+ if (isExclude) {
3464
+ return !typesArray.includes(bankAccount.type);
3465
+ }
3466
+ return typesArray.includes(bankAccount.type);
3467
+ });
3468
+ };
3469
+ /**
3470
+ * get amount of initial loans
3471
+ */
3472
+ BankAccountCollection.prototype.getInitialLoanAmount = function () {
3473
+ return this.getByType(TYPE_LOAN)
3474
+ .reduce(function (sum, bankAccount) {
3475
+ return sum += bankAccount.balances.length ? bankAccount.getOpeningBalance() : 0;
3476
+ }, 0);
3477
+ };
3478
+ /**
3479
+ * get amount of current loans
3480
+ */
3481
+ BankAccountCollection.prototype.getCurrentLoanAmount = function () {
3482
+ return this.getByType(TYPE_LOAN)
3483
+ .reduce(function (sum, bankAccount) {
3484
+ return sum += bankAccount.currentBalance;
3485
+ }, 0);
3486
+ };
3487
+ /**
3488
+ * get collection filtered by property id
3489
+ */
3490
+ BankAccountCollection.prototype.getByPropertyId = function (id) {
3491
+ return new BankAccountCollection(this.items.filter(function (bankAccount) {
3492
+ return bankAccount.bankAccountProperties.find(function (bankAccountProperty) {
3493
+ return bankAccountProperty.property.id === id;
3494
+ });
3495
+ }));
3496
+ };
3497
+ /**
3498
+ * get collection filtered by properties ids
3499
+ */
3500
+ BankAccountCollection.prototype.getByPropertiesIds = function (ids) {
3501
+ return new BankAccountCollection(this.items.filter(function (bankAccount) {
3502
+ return bankAccount.bankAccountProperties.find(function (bankAccountProperty) {
3503
+ return ids.includes(bankAccountProperty.property.id);
3504
+ });
3505
+ }));
3506
+ };
3507
+ /**
3508
+ * get collection of active bank accounts
3509
+ */
3510
+ BankAccountCollection.prototype.getActiveBankAccounts = function () {
3511
+ return new BankAccountCollection(this.items.filter(function (bankAccount) {
3512
+ return bankAccount.isActive();
3513
+ }));
3514
+ };
3515
+ /**
3516
+ * get reduction of loan (reduction of principle) percentage
3517
+ */
3518
+ BankAccountCollection.prototype.getPrincipleReductionPercent = function () {
3519
+ var initialLoans = this.getInitialLoanAmount();
3520
+ var currentLoans = this.getCurrentLoanAmount();
3521
+ if (!initialLoans) {
3522
+ return 0;
3523
+ }
3524
+ return (initialLoans - currentLoans) / initialLoans * 100;
3525
+ };
3526
+ /**
3527
+ * Get collection of loan bank accounts
3528
+ */
3529
+ BankAccountCollection.prototype.getLoanAccounts = function () {
3530
+ return new BankAccountCollection(this.getByType(TYPE_LOAN));
3531
+ };
3532
+ BankAccountCollection.prototype.getSavingsAccounts = function () {
3533
+ return new BankAccountCollection(this.getByType(TYPE_LOAN, true));
3534
+ };
3535
+ BankAccountCollection.prototype.getOpeningBalance = function () {
3536
+ return this.items.reduce(function (sum, bankAccount) { return sum + bankAccount.getOpeningBalance(); }, 0);
3537
+ };
3538
+ Object.defineProperty(BankAccountCollection.prototype, "currentBalance", {
3539
+ get: function () {
3540
+ return this.sumBy('currentBalance');
3541
+ },
3542
+ enumerable: false,
3543
+ configurable: true
3544
+ });
3545
+ /**
3546
+ * Get Collection of bank accounts with property tank type
3547
+ */
3548
+ BankAccountCollection.prototype.getPropertyBankAccounts = function () {
3549
+ return new BankAccountCollection(this.items.filter(function (bankAccount) { return bankAccount.isPropertyTank(); }));
3550
+ };
3551
+ /**
3552
+ * Get Collection of bank accounts with work tank type
3553
+ */
3554
+ BankAccountCollection.prototype.getWorkBankAccounts = function () {
3555
+ return new BankAccountCollection(this.items.filter(function (bankAccount) { return bankAccount.isWorkTank(); }));
3556
+ };
3557
+ /**
3558
+ * Get Collection of bank accounts by tank type
3559
+ */
3560
+ BankAccountCollection.prototype.getByTankType = function (tankType) {
3561
+ return new BankAccountCollection(this.items.filter(function (bankAccount) { return bankAccount.tankType === tankType; }));
3562
+ };
3563
+ /**
3564
+ * Get list of all bank account properties
3565
+ */
3566
+ BankAccountCollection.prototype.getBankAccountPropertiesList = function () {
3567
+ return flatten__default["default"](this.items.map(function (bankAccount) {
3568
+ return bankAccount.bankAccountProperties;
3569
+ }));
3570
+ };
3571
+ /**
3572
+ * Get lis of unique properties from all bank accounts properties
3573
+ */
3574
+ BankAccountCollection.prototype.getProperties = function () {
3575
+ return uniqBy__default["default"](this.getBankAccountPropertiesList().map(function (bankAccountProperty) {
3576
+ return bankAccountProperty.property;
3577
+ }), 'id');
3578
+ };
3579
+ BankAccountCollection.prototype.getPropertyBalanceAmount = function (propertyId) {
3580
+ return this.items.reduce(function (sum, bankAccount) {
3581
+ return sum + bankAccount.getPropertyBalanceAmount(propertyId);
3582
+ }, 0);
3583
+ };
3584
+ return BankAccountCollection;
3585
+ }(Collection));
3420
3586
 
3421
3587
  /**
3422
3588
  * BankConnection means user account at specific bank (usually each user has only one at the same bank)
@@ -3432,16 +3598,26 @@
3432
3598
  }
3433
3599
  BankConnectionService.prototype.listenEvents = function () {
3434
3600
  this.listenToAddedBankAccounts();
3435
- this.listenBasiqJobCreated();
3436
- this.listenConnectionUpdated();
3437
3601
  this.listenNotifications();
3438
3602
  };
3439
3603
  BankConnectionService.prototype.add = function (bankConnection) {
3440
3604
  var _this = this;
3441
3605
  return this.http.post(this.environment.apiV2 + "/" + this.url, bankConnection)
3442
3606
  .pipe(operators.map(function (bankConnectionBase) {
3443
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BANK_CONNECTION_ADDED, null));
3444
- return classTransformer.plainToClass(BankConnection, bankConnectionBase);
3607
+ var connection = classTransformer.plainToClass(BankConnection, bankConnectionBase);
3608
+ // We use this endpoint for create and reconnect bank connections because of basiq logic.
3609
+ // So we try to replace bank connection in cache for reconnection case.
3610
+ if (bankConnection.id) {
3611
+ var tempCache = cloneDeep__default["default"](_this.cache);
3612
+ replace(tempCache, connection);
3613
+ _this.cache = cloneDeep__default["default"](tempCache);
3614
+ _this.cacheSubject.next(tempCache);
3615
+ }
3616
+ else {
3617
+ _this.cache.push(connection);
3618
+ _this.cacheSubject.next(cloneDeep__default["default"](_this.cache));
3619
+ }
3620
+ return classTransformer.plainToClass(BankConnection, connection);
3445
3621
  }));
3446
3622
  };
3447
3623
  BankConnectionService.prototype.listenToAddedBankAccounts = function () {
@@ -3450,47 +3626,6 @@
3450
3626
  _this.resetCache();
3451
3627
  });
3452
3628
  };
3453
- /**
3454
- * When user log in to bank, basiq create a job. We create a bank connection with based on this job
3455
- */
3456
- BankConnectionService.prototype.listenBasiqJobCreated = function () {
3457
- var _this = this;
3458
- this.eventDispatcherService.on(exports.AppEventTypeEnum.BASIQ_JOB_CREATED).subscribe(function (result) {
3459
- // push connection to cache temporary to show it to user directly with pending status and not wait until backend loaded
3460
- var tempCache = cloneDeep__default["default"](_this.cache);
3461
- result.connection.setPending();
3462
- tempCache.push(result.connection);
3463
- _this.cache = tempCache;
3464
- _this.cacheSubject.next(tempCache);
3465
- _this.add(classTransformer.plainToClass(BankConnection, { basiqJob: { externalId: result.jobId } })).subscribe(function (newConnection) {
3466
- // replace temporary connection with real saved connection
3467
- // no replace() because connection does not have id yet
3468
- tempCache.splice(-1, 1, newConnection);
3469
- _this.cache = cloneDeep__default["default"](tempCache);
3470
- _this.cacheSubject.next(tempCache);
3471
- });
3472
- });
3473
- };
3474
- /**
3475
- * When basiq connection disconnected we create a basiq job and update this connection
3476
- */
3477
- BankConnectionService.prototype.listenConnectionUpdated = function () {
3478
- var _this = this;
3479
- this.eventDispatcherService.on(exports.AppEventTypeEnum.BASIQ_CONNECTION_UPDATED).subscribe(function (result) {
3480
- // replace connection to cache temporary to show pending status until backend loaded
3481
- var tempCache = cloneDeep__default["default"](_this.cache);
3482
- result.connection.setPending();
3483
- replace(tempCache, result.connection);
3484
- _this.cache = tempCache;
3485
- _this.cacheSubject.next(tempCache);
3486
- _this.add(classTransformer.plainToClass(BankConnection, { basiqJob: { externalId: result.jobId } })).subscribe(function (updatedConnection) {
3487
- // replace temporary connection again with real updated connection
3488
- replace(tempCache, updatedConnection);
3489
- _this.cache = cloneDeep__default["default"](tempCache);
3490
- _this.cacheSubject.next(tempCache);
3491
- });
3492
- });
3493
- };
3494
3629
  /**
3495
3630
  * Update cache when basiq login failed to get actual connections statuses
3496
3631
  */
@@ -3519,9 +3654,7 @@
3519
3654
  */
3520
3655
  var BasiqService = /** @class */ (function (_super) {
3521
3656
  __extends(BasiqService, _super);
3522
- function BasiqService(http, eventDispatcherService, environment, toastService,
3523
- // init BankConnectionService to listen events
3524
- bankConnectionService) {
3657
+ function BasiqService(http, eventDispatcherService, environment, toastService, bankConnectionService) {
3525
3658
  var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
3526
3659
  _this.http = http;
3527
3660
  _this.eventDispatcherService = eventDispatcherService;
@@ -3539,23 +3672,60 @@
3539
3672
  this.listenNotifications();
3540
3673
  };
3541
3674
  /**
3542
- * Create Basiq job for the new bank connection creation
3675
+ * Create a new Bank connection based on Basiq job.
3676
+ * Here we have nested requests because we need to get a job id before we create a bank connection.
3677
+ * There is no way to use event dispatcher because we expect some errors from bank-connections API, but in components
3678
+ * we interact with basiq service.
3543
3679
  */
3544
- BasiqService.prototype.createConnection = function (data, userId, connection) {
3680
+ BasiqService.prototype.createConnection = function (loginData, userId) {
3545
3681
  var _this = this;
3546
- return this.http.post(BasiqService.basiqApiUrl + "/users/" + userId + "/connections", data).pipe(operators.map(function (response) {
3547
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BASIQ_JOB_CREATED, { jobId: response.id, connection: connection }));
3548
- return response.id;
3682
+ // Send login data to basiq API to create a basiq job
3683
+ return this.http.post(BasiqService.basiqApiUrl + "/users/" + userId + "/connections", loginData)
3684
+ .pipe(operators.mergeMap(function (response) {
3685
+ // Create bank connection based on basiq job
3686
+ return _this.bankConnectionService.add(classTransformer.plainToClass(BankConnection, { basiqJob: { externalId: response.id } }));
3687
+ }), operators.catchError(function (error) {
3688
+ // Show error when user provided wrong login data
3689
+ if (error.status === 401) {
3690
+ _this.toastService.error('Invalid credentials');
3691
+ }
3692
+ return throwError.throwError(error);
3549
3693
  }));
3550
3694
  };
3551
3695
  /**
3552
3696
  * Update disconnected bank connection
3697
+ * Here we have nested requests because we need to get a job id before we create a bank connection.
3698
+ * There is no way to use event dispatcher because we expect some errors from bank-connections API, but in components
3699
+ * we interact with basiq service.
3553
3700
  */
3554
3701
  BasiqService.prototype.updateConnection = function (data, userId, connection) {
3555
3702
  var _this = this;
3556
- return this.http.post(BasiqService.basiqApiUrl + "/users/" + userId + "/connections", Object.assign(data, { id: connection.externalId })).pipe(operators.map(function (response) {
3557
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.BASIQ_CONNECTION_UPDATED, { jobId: response.id, connection: connection }));
3558
- return response.id;
3703
+ // Send login data to basiq API to create a basiq job
3704
+ return this.http.post(BasiqService.basiqApiUrl + "/users/" + userId + "/connections", Object.assign(data, { id: connection.externalId }))
3705
+ .pipe(
3706
+ // Create bank connection based on basiq job
3707
+ operators.mergeMap(function (response) {
3708
+ return _this.bankConnectionService.add(classTransformer.plainToClass(BankConnection, Object.assign({ id: connection.id, basiqJob: { externalId: response.id } })));
3709
+ }), operators.catchError(function (error) {
3710
+ // Show error when user provided wrong login data
3711
+ if (error.status === 401) {
3712
+ _this.toastService.error('Invalid credentials');
3713
+ }
3714
+ // Show error when user provided another login (not login he used before)
3715
+ if (error.status === 400) {
3716
+ _this.toastService.error('Please enter the login you used before');
3717
+ }
3718
+ return throwError.throwError(error);
3719
+ }));
3720
+ };
3721
+ BasiqService.prototype.getByConnection = function (connection) {
3722
+ return this.get().pipe(operators.map(function (bankAccounts) {
3723
+ return new BankAccountCollection(bankAccounts).filterBy('bankConnection.id', connection.id);
3724
+ }));
3725
+ };
3726
+ BasiqService.prototype.getNotImportedByConnection = function (savedAccounts, connection) {
3727
+ return this.getByConnection(connection).pipe(operators.map(function (bankAccounts) {
3728
+ return bankAccounts.removeBy('accountId', savedAccounts.mapBy('accountId'));
3559
3729
  }));
3560
3730
  };
3561
3731
  /**
@@ -3748,218 +3918,55 @@
3748
3918
  multi: true
3749
3919
  }
3750
3920
  ]
3751
- }]
3752
- }] });
3753
-
3754
- var TtCoreModule = /** @class */ (function () {
3755
- function TtCoreModule() {
3756
- }
3757
- TtCoreModule.forRoot = function (environment) {
3758
- localStorage.setItem('api_uri', environment['api_uri']);
3759
- return {
3760
- ngModule: TtCoreModule,
3761
- providers: [
3762
- {
3763
- provide: 'environment',
3764
- useValue: environment
3765
- }
3766
- ]
3767
- };
3768
- };
3769
- return TtCoreModule;
3770
- }());
3771
- TtCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
3772
- TtCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [i1$1.CommonModule,
3773
- InterceptorsModule] });
3774
- TtCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [[
3775
- i1$1.CommonModule,
3776
- InterceptorsModule
3777
- ]] });
3778
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, decorators: [{
3779
- type: i0.NgModule,
3780
- args: [{
3781
- declarations: [],
3782
- imports: [
3783
- i1$1.CommonModule,
3784
- InterceptorsModule
3785
- ]
3786
- }]
3787
- }] });
3788
-
3789
- var AccountSetupItemCollection = /** @class */ (function (_super) {
3790
- __extends(AccountSetupItemCollection, _super);
3791
- function AccountSetupItemCollection(items) {
3792
- var _this = _super.call(this, compact__default["default"](items)) || this;
3793
- _this.sortBy('isCompleted', false);
3794
- return _this;
3795
- }
3796
- AccountSetupItemCollection.prototype.isCompleted = function () {
3797
- return this.filterBy('isCompleted', true).length === this.length;
3798
- };
3799
- return AccountSetupItemCollection;
3800
- }(Collection));
3801
-
3802
- var BankCollection = /** @class */ (function (_super) {
3803
- __extends(BankCollection, _super);
3804
- function BankCollection(banks) {
3805
- var _this = _super.call(this, banks) || this;
3806
- _this.sortByPopularity();
3807
- return _this;
3808
- }
3809
- BankCollection.prototype.sortByPopularity = function () {
3810
- this.items.sort(function (bank1, bank2) {
3811
- // Banks already sorted on backend by name, so we just need to up top-10 banks
3812
- return (BankCollection.tobBanksIds.includes(bank1.id) && !BankCollection.tobBanksIds.includes(bank2.id)) ? -1 : 1;
3813
- });
3814
- };
3815
- return BankCollection;
3816
- }(Collection));
3817
- BankCollection.tobBanksIds = [124, 13, 134, 172, 126, 142, 135, 137, 138, 128];
3818
-
3819
- var TYPE_LOAN = [
3820
- exports.BankAccountTypeEnum.MORTGAGE,
3821
- exports.BankAccountTypeEnum.CREDIT_CARD,
3822
- exports.BankAccountTypeEnum.LOAN
3823
- ];
3824
-
3825
- /**
3826
- * Collection of bank accounts.
3827
- */
3828
- var BankAccountCollection = /** @class */ (function (_super) {
3829
- __extends(BankAccountCollection, _super);
3830
- function BankAccountCollection() {
3831
- return _super !== null && _super.apply(this, arguments) || this;
3832
- }
3833
- /**
3834
- * get list of bank accounts with passed types
3835
- */
3836
- BankAccountCollection.prototype.getByType = function (types, isExclude) {
3837
- if (isExclude === void 0) { isExclude = false; }
3838
- // get types always as array (if only one passed)
3839
- var typesArray = concat__default["default"](types);
3840
- return this.items.filter(function (bankAccount) {
3841
- if (isExclude) {
3842
- return !typesArray.includes(bankAccount.type);
3843
- }
3844
- return typesArray.includes(bankAccount.type);
3845
- });
3846
- };
3847
- /**
3848
- * get amount of initial loans
3849
- */
3850
- BankAccountCollection.prototype.getInitialLoanAmount = function () {
3851
- return this.getByType(TYPE_LOAN)
3852
- .reduce(function (sum, bankAccount) {
3853
- return sum += bankAccount.balances.length ? bankAccount.getOpeningBalance() : 0;
3854
- }, 0);
3855
- };
3856
- /**
3857
- * get amount of current loans
3858
- */
3859
- BankAccountCollection.prototype.getCurrentLoanAmount = function () {
3860
- return this.getByType(TYPE_LOAN)
3861
- .reduce(function (sum, bankAccount) {
3862
- return sum += bankAccount.currentBalance;
3863
- }, 0);
3864
- };
3865
- /**
3866
- * get collection filtered by property id
3867
- */
3868
- BankAccountCollection.prototype.getByPropertyId = function (id) {
3869
- return new BankAccountCollection(this.items.filter(function (bankAccount) {
3870
- return bankAccount.bankAccountProperties.find(function (bankAccountProperty) {
3871
- return bankAccountProperty.property.id === id;
3872
- });
3873
- }));
3874
- };
3875
- /**
3876
- * get collection filtered by properties ids
3877
- */
3878
- BankAccountCollection.prototype.getByPropertiesIds = function (ids) {
3879
- return new BankAccountCollection(this.items.filter(function (bankAccount) {
3880
- return bankAccount.bankAccountProperties.find(function (bankAccountProperty) {
3881
- return ids.includes(bankAccountProperty.property.id);
3882
- });
3883
- }));
3884
- };
3885
- /**
3886
- * get collection of active bank accounts
3887
- */
3888
- BankAccountCollection.prototype.getActiveBankAccounts = function () {
3889
- return new BankAccountCollection(this.items.filter(function (bankAccount) {
3890
- return bankAccount.isActive();
3891
- }));
3892
- };
3893
- /**
3894
- * get reduction of loan (reduction of principle) percentage
3895
- */
3896
- BankAccountCollection.prototype.getPrincipleReductionPercent = function () {
3897
- var initialLoans = this.getInitialLoanAmount();
3898
- var currentLoans = this.getCurrentLoanAmount();
3899
- if (!initialLoans) {
3900
- return 0;
3901
- }
3902
- return (initialLoans - currentLoans) / initialLoans * 100;
3903
- };
3904
- /**
3905
- * Get collection of loan bank accounts
3906
- */
3907
- BankAccountCollection.prototype.getLoanAccounts = function () {
3908
- return new BankAccountCollection(this.getByType(TYPE_LOAN));
3909
- };
3910
- BankAccountCollection.prototype.getSavingsAccounts = function () {
3911
- return new BankAccountCollection(this.getByType(TYPE_LOAN, true));
3912
- };
3913
- BankAccountCollection.prototype.getOpeningBalance = function () {
3914
- return this.items.reduce(function (sum, bankAccount) { return sum + bankAccount.getOpeningBalance(); }, 0);
3915
- };
3916
- Object.defineProperty(BankAccountCollection.prototype, "currentBalance", {
3917
- get: function () {
3918
- return this.sumBy('currentBalance');
3919
- },
3920
- enumerable: false,
3921
- configurable: true
3922
- });
3923
- /**
3924
- * Get Collection of bank accounts with property tank type
3925
- */
3926
- BankAccountCollection.prototype.getPropertyBankAccounts = function () {
3927
- return new BankAccountCollection(this.items.filter(function (bankAccount) { return bankAccount.isPropertyTank(); }));
3928
- };
3929
- /**
3930
- * Get Collection of bank accounts with work tank type
3931
- */
3932
- BankAccountCollection.prototype.getWorkBankAccounts = function () {
3933
- return new BankAccountCollection(this.items.filter(function (bankAccount) { return bankAccount.isWorkTank(); }));
3934
- };
3935
- /**
3936
- * Get Collection of bank accounts by tank type
3937
- */
3938
- BankAccountCollection.prototype.getByTankType = function (tankType) {
3939
- return new BankAccountCollection(this.items.filter(function (bankAccount) { return bankAccount.tankType === tankType; }));
3940
- };
3941
- /**
3942
- * Get list of all bank account properties
3943
- */
3944
- BankAccountCollection.prototype.getBankAccountPropertiesList = function () {
3945
- return flatten__default["default"](this.items.map(function (bankAccount) {
3946
- return bankAccount.bankAccountProperties;
3947
- }));
3948
- };
3949
- /**
3950
- * Get lis of unique properties from all bank accounts properties
3951
- */
3952
- BankAccountCollection.prototype.getProperties = function () {
3953
- return uniqBy__default["default"](this.getBankAccountPropertiesList().map(function (bankAccountProperty) {
3954
- return bankAccountProperty.property;
3955
- }), 'id');
3921
+ }]
3922
+ }] });
3923
+
3924
+ var TtCoreModule = /** @class */ (function () {
3925
+ function TtCoreModule() {
3926
+ }
3927
+ TtCoreModule.forRoot = function (environment) {
3928
+ localStorage.setItem('api_uri', environment['api_uri']);
3929
+ return {
3930
+ ngModule: TtCoreModule,
3931
+ providers: [
3932
+ {
3933
+ provide: 'environment',
3934
+ useValue: environment
3935
+ }
3936
+ ]
3937
+ };
3956
3938
  };
3957
- BankAccountCollection.prototype.getPropertyBalanceAmount = function (propertyId) {
3958
- return this.items.reduce(function (sum, bankAccount) {
3959
- return sum + bankAccount.getPropertyBalanceAmount(propertyId);
3960
- }, 0);
3939
+ return TtCoreModule;
3940
+ }());
3941
+ TtCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
3942
+ TtCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [i1$1.CommonModule,
3943
+ InterceptorsModule] });
3944
+ TtCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, imports: [[
3945
+ i1$1.CommonModule,
3946
+ InterceptorsModule
3947
+ ]] });
3948
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TtCoreModule, decorators: [{
3949
+ type: i0.NgModule,
3950
+ args: [{
3951
+ declarations: [],
3952
+ imports: [
3953
+ i1$1.CommonModule,
3954
+ InterceptorsModule
3955
+ ]
3956
+ }]
3957
+ }] });
3958
+
3959
+ var AccountSetupItemCollection = /** @class */ (function (_super) {
3960
+ __extends(AccountSetupItemCollection, _super);
3961
+ function AccountSetupItemCollection(items) {
3962
+ var _this = _super.call(this, compact__default["default"](items)) || this;
3963
+ _this.sortBy('isCompleted', false);
3964
+ return _this;
3965
+ }
3966
+ AccountSetupItemCollection.prototype.isCompleted = function () {
3967
+ return this.filterBy('isCompleted', true).length === this.length;
3961
3968
  };
3962
- return BankAccountCollection;
3969
+ return AccountSetupItemCollection;
3963
3970
  }(Collection));
3964
3971
 
3965
3972
  exports.TransactionOperationEnum = void 0;
@@ -8301,6 +8308,42 @@
8301
8308
  return DepreciationReceipt;
8302
8309
  }(DepreciationReceipt$1));
8303
8310
 
8311
+ /**
8312
+ * List of objects grouped by passed property
8313
+ */
8314
+ var Dictionary = /** @class */ (function () {
8315
+ function Dictionary(items, path) {
8316
+ if (path === void 0) { path = 'id'; }
8317
+ this.items = {};
8318
+ if (!items.length) {
8319
+ return;
8320
+ }
8321
+ // Do nothing if provided path was not found in the 1st item
8322
+ if (!hasIn__default["default"](items[0], path.split('.')[0])) {
8323
+ return;
8324
+ }
8325
+ this.groupItems(items, path);
8326
+ }
8327
+ Dictionary.prototype.add = function (key, value) {
8328
+ this.items[key] = value;
8329
+ };
8330
+ Dictionary.prototype.get = function (key) {
8331
+ return this.items[key] ? this.items[key] : null;
8332
+ };
8333
+ Dictionary.prototype.groupItems = function (items, path) {
8334
+ var _this = this;
8335
+ items.forEach(function (item) {
8336
+ var key = get__default["default"](item, path);
8337
+ // if object does not have property for grouping it will be grouped as 'other'
8338
+ if (key === undefined) {
8339
+ key = 'other';
8340
+ }
8341
+ _this.items[key] = item;
8342
+ });
8343
+ };
8344
+ return Dictionary;
8345
+ }());
8346
+
8304
8347
  var Document$1 = /** @class */ (function (_super) {
8305
8348
  __extends(Document, _super);
8306
8349
  function Document() {
@@ -8405,6 +8448,17 @@
8405
8448
  classTransformer.Type(function () { return User; })
8406
8449
  ], EmployeeInvite.prototype, "employee", void 0);
8407
8450
 
8451
+ /**
8452
+ * any event happened in the app, which needs to be handled somehow (distributed to other part of the app)
8453
+ */
8454
+ var AppEvent = /** @class */ (function () {
8455
+ function AppEvent(type, payload) {
8456
+ this.type = type;
8457
+ this.payload = payload;
8458
+ }
8459
+ return AppEvent;
8460
+ }());
8461
+
8408
8462
  exports.ExportFormatEnum = void 0;
8409
8463
  (function (ExportFormatEnum) {
8410
8464
  ExportFormatEnum["PDF"] = "PDF";
@@ -10444,6 +10498,11 @@
10444
10498
  return bankAccounts.filter(function (bankAccount) { return bankAccount.isOwner(+localStorage.getItem('userId')); });
10445
10499
  }));
10446
10500
  };
10501
+ BankAccountService.prototype.getByConnection = function (connection) {
10502
+ return this.get().pipe(operators.map(function (bankAccounts) {
10503
+ return new BankAccountCollection(bankAccounts).filterBy('bankConnection.id', connection.id);
10504
+ }));
10505
+ };
10447
10506
  /**
10448
10507
  * Listen to EventDispatcherService events
10449
10508
  */
@@ -11158,6 +11217,12 @@
11158
11217
  _this.isHydra = true;
11159
11218
  return _this;
11160
11219
  }
11220
+ BankService.prototype.get = function () {
11221
+ return _super.prototype.get.call(this).pipe(operators.map(function (banks) {
11222
+ // exclude basiq banks without login fields (basiq may return broken banks without loginFields)
11223
+ return banks.filter(function (bank) { return !bank.externalId || (bank.externalId && bank.loginFields); });
11224
+ }));
11225
+ };
11161
11226
  return BankService;
11162
11227
  }(RestService));
11163
11228
  BankService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: BankService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -14187,6 +14252,9 @@
14187
14252
  UserService.prototype.resetPassword = function (newPassword, resetToken) {
14188
14253
  return this.http.put(this.environment.apiV2 + "/users/password/reset", { newPassword: newPassword, resetToken: resetToken });
14189
14254
  };
14255
+ UserService.prototype.resendConfirmationEmail = function (email) {
14256
+ return this.http.post(this.environment.apiV2 + "/users/confirmation/resend", { email: email });
14257
+ };
14190
14258
  /**
14191
14259
  * Confirm registered user
14192
14260
  */
@@ -14517,6 +14585,102 @@
14517
14585
  }]
14518
14586
  }] });
14519
14587
 
14588
+ var ERROR_EMAIL_PERMISSION = 'Access to email denied. Please provide access to email in facebook.';
14589
+ var FacebookService = /** @class */ (function () {
14590
+ /**
14591
+ * @TODO when google login will be done, it needs to be moved to an abstract class
14592
+ */
14593
+ function FacebookService(http, toastService, jwtService, router, environment) {
14594
+ this.http = http;
14595
+ this.toastService = toastService;
14596
+ this.jwtService = jwtService;
14597
+ this.router = router;
14598
+ this.environment = environment;
14599
+ this.isLoggedInSubject = new rxjs.BehaviorSubject(!this.jwtService.isTokenExpired());
14600
+ this.isFacebookEnabled = !!environment['facebookAppId'];
14601
+ }
14602
+ FacebookService.prototype.login = function (redirectUrl) {
14603
+ if (redirectUrl === void 0) { redirectUrl = '/client'; }
14604
+ return __awaiter(this, void 0, void 0, function () {
14605
+ var accessToken;
14606
+ var _this = this;
14607
+ return __generator(this, function (_a) {
14608
+ switch (_a.label) {
14609
+ case 0: return [4 /*yield*/, this.getAccessToken()];
14610
+ case 1:
14611
+ accessToken = _a.sent();
14612
+ this.http.post(this.environment.apiV2 + "/users/authentication/facebook", { accessToken: accessToken })
14613
+ .subscribe(function (response) {
14614
+ _this.setAuth(response);
14615
+ _this.router.navigate([redirectUrl]);
14616
+ }, function (error) {
14617
+ _this.toastService.error(error.error.violations[0].message);
14618
+ _this.logout();
14619
+ });
14620
+ return [2 /*return*/];
14621
+ }
14622
+ });
14623
+ });
14624
+ };
14625
+ /**
14626
+ * save user's auth tokens
14627
+ * @TODO move to abstract class
14628
+ */
14629
+ FacebookService.prototype.setAuth = function (response) {
14630
+ this.jwtService.saveTokens(response);
14631
+ this.isLoggedInSubject.next(true);
14632
+ };
14633
+ /**
14634
+ * get facebook auth access token
14635
+ */
14636
+ FacebookService.prototype.getAccessToken = function () {
14637
+ var _this = this;
14638
+ return new Promise(function (resolve) {
14639
+ FB.login(function (response) {
14640
+ // authResponse will be empty if you close the Facebook login window or enter incorrect user data
14641
+ if (!response.authResponse) {
14642
+ return;
14643
+ }
14644
+ if (!response.authResponse.grantedScopes.includes('email')) {
14645
+ _this.toastService.error(ERROR_EMAIL_PERMISSION);
14646
+ return;
14647
+ }
14648
+ resolve(response.authResponse.accessToken);
14649
+ }, FacebookService.authOptions);
14650
+ });
14651
+ };
14652
+ /**
14653
+ * logout user from facebook.
14654
+ * Need to logout when user is trying to login with facebook with manually registered email
14655
+ */
14656
+ FacebookService.prototype.logout = function () {
14657
+ return new Promise(function (resolve, reject) {
14658
+ FB.logout(function (response) {
14659
+ resolve(response);
14660
+ });
14661
+ });
14662
+ };
14663
+ return FacebookService;
14664
+ }());
14665
+ FacebookService.authOptions = {
14666
+ scope: 'email, public_profile',
14667
+ auth_type: 'rerequest',
14668
+ return_scopes: true
14669
+ };
14670
+ FacebookService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FacebookService, deps: [{ token: i1__namespace.HttpClient }, { token: ToastService }, { token: JwtService }, { token: i1__namespace$2.Router }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
14671
+ FacebookService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FacebookService, providedIn: 'root' });
14672
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: FacebookService, decorators: [{
14673
+ type: i0.Injectable,
14674
+ args: [{
14675
+ providedIn: 'root'
14676
+ }]
14677
+ }], ctorParameters: function () {
14678
+ return [{ type: i1__namespace.HttpClient }, { type: ToastService }, { type: JwtService }, { type: i1__namespace$2.Router }, { type: undefined, decorators: [{
14679
+ type: i0.Inject,
14680
+ args: ['environment']
14681
+ }] }];
14682
+ } });
14683
+
14520
14684
  // deep clone for entity
14521
14685
  function cloneDeep(array) {
14522
14686
  return JSON.parse(JSON.stringify(array));
@@ -14594,9 +14758,9 @@
14594
14758
  var AbstractForm = /** @class */ (function (_super) {
14595
14759
  __extends(AbstractForm, _super);
14596
14760
  function AbstractForm(controls, model, validatorOrOpts, asyncValidator) {
14597
- if (model === void 0) { model = {}; }
14598
14761
  var _this = _super.call(this, controls, validatorOrOpts, asyncValidator) || this;
14599
- _this.model = model;
14762
+ _this.onSubmit = new i0.EventEmitter();
14763
+ _this.model = model || _this.createModelInstance();
14600
14764
  _this.modelClass = _this.model.constructor;
14601
14765
  return _this;
14602
14766
  }
@@ -14612,11 +14776,20 @@
14612
14776
  if (!this.valid) {
14613
14777
  return null;
14614
14778
  }
14615
- return classTransformer.plainToClass(this.modelClass, Object.assign({}, this.model, this.value, data));
14779
+ var model = this.createModelInstance(Object.assign({}, this.model, this.value, data));
14780
+ this.onSubmit.emit(model);
14781
+ return model;
14782
+ };
14783
+ AbstractForm.prototype.createModelInstance = function (data) {
14784
+ if (data === void 0) { data = {}; }
14785
+ return classTransformer.plainToClass(this.modelClass, data);
14616
14786
  };
14617
14787
  return AbstractForm;
14618
14788
  }(forms.FormGroup));
14619
14789
 
14790
+ /**
14791
+ * Form with bank account loan details
14792
+ */
14620
14793
  var BankAccountLoanForm = /** @class */ (function (_super) {
14621
14794
  __extends(BankAccountLoanForm, _super);
14622
14795
  function BankAccountLoanForm(loan) {
@@ -14636,117 +14809,154 @@
14636
14809
  return BankAccountLoanForm;
14637
14810
  }(AbstractForm));
14638
14811
 
14639
- var BankAccountPropertyForm = /** @class */ (function (_super) {
14640
- __extends(BankAccountPropertyForm, _super);
14641
- function BankAccountPropertyForm(isLoan, bankAccountProperty) {
14642
- if (bankAccountProperty === void 0) { bankAccountProperty = classTransformer.plainToClass(BankAccountProperty, {}); }
14643
- return _super.call(this, {
14644
- property: new forms.FormControl(bankAccountProperty.property, forms.Validators.required),
14645
- percent: new forms.FormControl({ value: bankAccountProperty.percent, disabled: !isLoan }, forms.Validators.required)
14646
- }, bankAccountProperty) || this;
14647
- }
14648
- return BankAccountPropertyForm;
14649
- }(AbstractForm));
14650
-
14812
+ /**
14813
+ * Form array with bank account properties
14814
+ */
14651
14815
  var BankAccountPropertiesForm = /** @class */ (function (_super) {
14652
14816
  __extends(BankAccountPropertiesForm, _super);
14653
- function BankAccountPropertiesForm(isLoan, bankAccountProperties) {
14654
- if (bankAccountProperties === void 0) { bankAccountProperties = []; }
14655
- var _this = _super.call(this, bankAccountProperties.length
14656
- ? bankAccountProperties.map(function (bankAccountProperty) { return new BankAccountPropertyForm(isLoan, bankAccountProperty); })
14657
- : [new BankAccountPropertyForm(isLoan)]) || this;
14658
- _this.isLoan = isLoan;
14659
- _this.bankAccountProperties = bankAccountProperties;
14660
- return _this;
14817
+ function BankAccountPropertiesForm(bankAccountProperties) {
14818
+ if (bankAccountProperties === void 0) { bankAccountProperties = [classTransformer.plainToClass(BankAccountProperty, {})]; }
14819
+ return _super.call(this, bankAccountProperties.map(function (bankAccountProperty) {
14820
+ return new forms.FormGroup({
14821
+ property: new forms.FormControl(bankAccountProperty.property, forms.Validators.required),
14822
+ percent: new forms.FormControl(bankAccountProperty.percent, forms.Validators.required)
14823
+ });
14824
+ })) || this;
14661
14825
  }
14662
14826
  BankAccountPropertiesForm.prototype.add = function () {
14663
- this.push(new BankAccountPropertyForm(this.isLoan));
14827
+ this.push(new forms.FormGroup({
14828
+ property: new forms.FormControl(null, forms.Validators.required),
14829
+ percent: new forms.FormControl({
14830
+ value: 100,
14831
+ disabled: !this.at(0).contains('percent')
14832
+ }, forms.Validators.required)
14833
+ }));
14834
+ };
14835
+ BankAccountPropertiesForm.prototype.enablePercent = function () {
14836
+ this.controls.forEach(function (propertyFormGroup) {
14837
+ propertyFormGroup.get('percent').enable();
14838
+ });
14839
+ };
14840
+ BankAccountPropertiesForm.prototype.disablePercent = function () {
14841
+ this.controls.forEach(function (propertyFormGroup) {
14842
+ propertyFormGroup.get('percent').disable();
14843
+ });
14664
14844
  };
14665
14845
  return BankAccountPropertiesForm;
14666
14846
  }(forms.FormArray));
14667
14847
 
14668
14848
  /**
14669
- * Form for additional data for bank accounts. Allow user to set tank type, loan and properties for new not-saved bank accounts.
14670
- * Works with manual and basiq bank accounts.
14849
+ * Form is using for import basiq bank accounts.
14850
+ * Basiq accounts has all data except tank type, properties and loan partially
14671
14851
  */
14672
- var BankAccountForm = /** @class */ (function (_super) {
14673
- __extends(BankAccountForm, _super);
14674
- function BankAccountForm(bankAccount) {
14675
- if (bankAccount === void 0) { bankAccount = classTransformer.plainToClass(BankAccount, {}); }
14852
+ var BankAccountImportForm = /** @class */ (function (_super) {
14853
+ __extends(BankAccountImportForm, _super);
14854
+ function BankAccountImportForm(bankAccount) {
14676
14855
  var _this = _super.call(this, {
14677
14856
  tankType: new forms.FormControl(bankAccount.tankType, forms.Validators.required),
14678
14857
  }, bankAccount) || this;
14679
- _this.bankAccount = bankAccount;
14680
14858
  if (bankAccount.isLoan()) {
14681
14859
  _this.addControl('loan', new BankAccountLoanForm(bankAccount.loan));
14682
14860
  }
14861
+ // basiq account import form should be disabled (unchecked) by default
14862
+ _this.disable();
14683
14863
  _this.listenEvents();
14684
14864
  return _this;
14685
14865
  }
14686
- BankAccountForm.prototype.listenEvents = function () {
14866
+ BankAccountImportForm.prototype.listenEvents = function () {
14687
14867
  this.listenTankTypeChanges();
14688
- this.listenValueChanges();
14689
- };
14690
- Object.defineProperty(BankAccountForm.prototype, "properties", {
14691
- get: function () {
14692
- return this.get('bankAccountProperties');
14693
- },
14694
- enumerable: false,
14695
- configurable: true
14696
- });
14697
- BankAccountForm.prototype.isLoan = function () {
14698
- return BankAccount.loanTypes.includes(this.bankAccount.type);
14699
- };
14700
- BankAccountForm.prototype.isPropertyTank = function () {
14701
- return this.get('tankType').value === exports.TankTypeEnum.PROPERTY;
14702
- };
14703
- BankAccountForm.prototype.confirm = function () {
14704
- this.markAllAsTouched();
14705
- if (this.invalid) {
14706
- return;
14707
- }
14708
- this.isConfirmed = true;
14709
- };
14710
- BankAccountForm.prototype.addPropertiesArray = function () {
14711
- var control = new BankAccountPropertiesForm(this.isLoan(), this.bankAccount.bankAccountProperties);
14712
- // Default form behaviour is: if we add enabled form control to disabled form group then this form group enable.
14713
- // Disable form control before add to avoid form group enabling.
14714
- if (this.disabled) {
14715
- control.disable();
14716
- }
14717
- this.addControl('bankAccountProperties', control);
14718
14868
  };
14719
14869
  /**
14720
- * Add/Remove properties form array depending on selected tank type
14870
+ * Add/Remove bank account properties form depends on selected tank type
14721
14871
  */
14722
- BankAccountForm.prototype.listenTankTypeChanges = function () {
14723
- var _this = this;
14724
- this.get('tankType').valueChanges.subscribe(function () {
14725
- _this.isPropertyTank() ? _this.addPropertiesArray() : _this.removeControl('bankAccountProperties');
14726
- });
14727
- };
14728
- BankAccountForm.prototype.listenValueChanges = function () {
14872
+ BankAccountImportForm.prototype.listenTankTypeChanges = function () {
14729
14873
  var _this = this;
14730
- this.valueChanges.subscribe(function () {
14731
- _this.isConfirmed = false;
14874
+ this.get('tankType').valueChanges.subscribe(function (tankType) {
14875
+ if (tankType === exports.TankTypeEnum.PROPERTY) {
14876
+ _this.addControl('bankAccountProperties', new BankAccountPropertiesForm());
14877
+ // property percent allowed only for loan bank accounts
14878
+ if (!_this.contains('loan')) {
14879
+ _this.get('bankAccountProperties').disablePercent();
14880
+ }
14881
+ }
14882
+ else {
14883
+ _this.removeControl('bankAccountProperties');
14884
+ }
14732
14885
  });
14733
14886
  };
14734
- return BankAccountForm;
14887
+ return BankAccountImportForm;
14735
14888
  }(AbstractForm));
14736
14889
 
14737
14890
  /**
14738
- * Form is using for manual bank account creation (not Basiq), prepares bank account data for the next saving.
14891
+ * Form is using for single manual bank account creation (not Basiq)
14739
14892
  */
14740
14893
  var BankAccountAddManualForm = /** @class */ (function (_super) {
14741
14894
  __extends(BankAccountAddManualForm, _super);
14742
14895
  function BankAccountAddManualForm(connection) {
14743
- return _super.call(this, {
14896
+ var _this = _super.call(this, {
14744
14897
  type: new forms.FormControl(null, forms.Validators.required),
14745
14898
  accountName: new forms.FormControl(null, forms.Validators.required),
14746
14899
  currentBalance: new forms.FormControl(null, forms.Validators.required),
14747
14900
  accountNumber: new forms.FormControl(null, [forms.Validators.required, forms.Validators.pattern(BankAccountAddManualForm.accountNumberPattern)]),
14748
- }, classTransformer.plainToClass(BankAccount, { bankConnection: connection })) || this;
14901
+ tankType: new forms.FormControl(null, forms.Validators.required),
14902
+ }) || this;
14903
+ _this.connection = connection;
14904
+ _this.listenEvents();
14905
+ return _this;
14749
14906
  }
14907
+ BankAccountAddManualForm.prototype.listenEvents = function () {
14908
+ this.listenTypeChanges();
14909
+ this.listenTankTypeChanges();
14910
+ };
14911
+ /**
14912
+ * Add/Remove loan form depends on selected bank account type
14913
+ */
14914
+ BankAccountAddManualForm.prototype.listenTypeChanges = function () {
14915
+ var _this = this;
14916
+ this.get('type').valueChanges.subscribe(function (type) {
14917
+ if (BankAccount.loanTypes.includes(type)) {
14918
+ _this.addControl('loan', new BankAccountLoanForm());
14919
+ // property percent allowed only for loan bank accounts
14920
+ if (_this.contains('bankAccountProperties')) {
14921
+ _this.get('bankAccountProperties').enablePercent();
14922
+ }
14923
+ }
14924
+ else {
14925
+ _this.removeControl('loan');
14926
+ // property percent allowed only for loan bank accounts
14927
+ if (_this.contains('bankAccountProperties')) {
14928
+ _this.get('bankAccountProperties').disablePercent();
14929
+ }
14930
+ }
14931
+ });
14932
+ };
14933
+ /**
14934
+ * Add/Remove bank account properties form depends on selected tank type
14935
+ */
14936
+ BankAccountAddManualForm.prototype.listenTankTypeChanges = function () {
14937
+ var _this = this;
14938
+ this.get('tankType').valueChanges.subscribe(function (tankType) {
14939
+ if (tankType === exports.TankTypeEnum.PROPERTY) {
14940
+ _this.addControl('bankAccountProperties', new BankAccountPropertiesForm());
14941
+ // property percent allowed only for loan bank accounts
14942
+ if (_this.contains('loan')) {
14943
+ _this.get('bankAccountProperties').enablePercent();
14944
+ }
14945
+ else {
14946
+ _this.get('bankAccountProperties').disablePercent();
14947
+ }
14948
+ }
14949
+ else {
14950
+ _this.removeControl('bankAccountProperties');
14951
+ }
14952
+ });
14953
+ };
14954
+ /**
14955
+ * Attach bank connection to manual bank account
14956
+ */
14957
+ BankAccountAddManualForm.prototype.submit = function () {
14958
+ return _super.prototype.submit.call(this, { bankConnection: this.connection });
14959
+ };
14750
14960
  return BankAccountAddManualForm;
14751
14961
  }(AbstractForm));
14752
14962
  BankAccountAddManualForm.accountNumberPattern = '^[0-9]{6}[ ]{1}[0-9]{1,}$';
@@ -14773,18 +14983,74 @@
14773
14983
  };
14774
14984
  }
14775
14985
 
14776
- var BankAccountMigrateForm = /** @class */ (function (_super) {
14777
- __extends(BankAccountMigrateForm, _super);
14778
- function BankAccountMigrateForm() {
14779
- return _super.call(this, {
14780
- migrateFrom: new forms.FormControl(BankAccountMigrateForm.minDate, [forms.Validators.required, dateRangeValidator(BankAccountMigrateForm.minDate, BankAccountMigrateForm.maxDate)]),
14781
- migrateTo: new forms.FormControl(BankAccountMigrateForm.maxDate, [forms.Validators.required, dateRangeValidator(BankAccountMigrateForm.minDate, BankAccountMigrateForm.maxDate)])
14986
+ /**
14987
+ * Validator check if at least one control in formArray is enabled
14988
+ */
14989
+ function atLeastOneEnabledValidator(arrayName) {
14990
+ return function (formGroup) {
14991
+ return !!formGroup.get(arrayName).controls.find(function (control) { return control.enabled; })
14992
+ ? null
14993
+ : { arrayControlsDisabled: true };
14994
+ };
14995
+ }
14996
+
14997
+ /**
14998
+ * Form for import multiple basiq bank accounts
14999
+ */
15000
+ var BankAccountsImportForm = /** @class */ (function (_super) {
15001
+ __extends(BankAccountsImportForm, _super);
15002
+ function BankAccountsImportForm(bankAccounts) {
15003
+ var _this = _super.call(this, {
15004
+ migrateFrom: new forms.FormControl(BankAccountsImportForm.minDate, [forms.Validators.required, dateRangeValidator(BankAccountsImportForm.minDate, BankAccountsImportForm.maxDate)]),
15005
+ migrateTo: new forms.FormControl(BankAccountsImportForm.maxDate, [forms.Validators.required, dateRangeValidator(BankAccountsImportForm.minDate, BankAccountsImportForm.maxDate)]),
15006
+ bankAccounts: new forms.FormArray(bankAccounts.map(function (bankAccount) { return new BankAccountImportForm(bankAccount); }))
15007
+ }, [], {
15008
+ validators: [atLeastOneEnabledValidator('bankAccounts')]
14782
15009
  }) || this;
15010
+ _this.bankAccounts = bankAccounts;
15011
+ return _this;
14783
15012
  }
14784
- return BankAccountMigrateForm;
15013
+ BankAccountsImportForm.prototype.submit = function () {
15014
+ var e_1, _a;
15015
+ this.submitted = true;
15016
+ if (this.invalid) {
15017
+ return null;
15018
+ }
15019
+ var bankAccounts = [];
15020
+ try {
15021
+ // form is valid when all selected bank accounts forms are valid
15022
+ for (var _b = __values(this.get('bankAccounts').controls), _c = _b.next(); !_c.done; _c = _b.next()) {
15023
+ var bankAccountImportForm = _c.value;
15024
+ // skip disabled forms
15025
+ if (bankAccountImportForm.disabled) {
15026
+ continue;
15027
+ }
15028
+ var bankAccount = bankAccountImportForm.submit({
15029
+ migrateFrom: this.value.migrateFrom,
15030
+ migrateTo: this.value.migrateTo
15031
+ });
15032
+ if (!bankAccount) {
15033
+ return null;
15034
+ }
15035
+ bankAccounts.push(bankAccount);
15036
+ }
15037
+ }
15038
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
15039
+ finally {
15040
+ try {
15041
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
15042
+ }
15043
+ finally { if (e_1) throw e_1.error; }
15044
+ }
15045
+ if (!bankAccounts.length) {
15046
+ return null;
15047
+ }
15048
+ return bankAccounts;
15049
+ };
15050
+ return BankAccountsImportForm;
14785
15051
  }(AbstractForm));
14786
- BankAccountMigrateForm.minDate = new FinancialYear().prevFinYear.startDate;
14787
- BankAccountMigrateForm.maxDate = new Date();
15052
+ BankAccountsImportForm.minDate = new FinancialYear().prevFinYear.startDate;
15053
+ BankAccountsImportForm.maxDate = new Date();
14788
15054
 
14789
15055
  /**
14790
15056
  * Form with basiq bank login fields.
@@ -14817,15 +15083,11 @@
14817
15083
 
14818
15084
  /**
14819
15085
  * Validation function for autocomplete fields. Checks that the user should select a value from a list rather than type in input field
15086
+ * @TODO Alex: create class AppValidators with static methods and move there all custom validators (line Angular Validators)
14820
15087
  */
14821
- function requireAutocomplete() {
15088
+ function autocompleteValidator() {
14822
15089
  return function (control) {
14823
- if (typeof control.value === 'string' && !!control.value) {
14824
- return { notFromList: true };
14825
- }
14826
- else {
14827
- return null;
14828
- }
15090
+ return (!control.value || (typeof control.value === 'object')) ? null : { notFromList: true };
14829
15091
  };
14830
15092
  }
14831
15093
 
@@ -14867,21 +15129,6 @@
14867
15129
  };
14868
15130
  }
14869
15131
 
14870
- /**
14871
- * Validation function, that checks that the user should select a value from a list rather than type in input field
14872
- */
14873
- function requireSelectValidator() {
14874
- return function (control) {
14875
- var selection = control.value;
14876
- if (typeof selection === 'string' && !!selection) {
14877
- return { notFromList: true };
14878
- }
14879
- else {
14880
- return null;
14881
- }
14882
- };
14883
- }
14884
-
14885
15132
  var ClientIncomeTypesForm = /** @class */ (function (_super) {
14886
15133
  __extends(ClientIncomeTypesForm, _super);
14887
15134
  function ClientIncomeTypesForm(clientIncomeTypes) {
@@ -14909,13 +15156,14 @@
14909
15156
  return LoginForm;
14910
15157
  }(AbstractForm));
14911
15158
 
15159
+ // @TODO Alex: Create a model and handle request fields via class-transformer
14912
15160
  var PasswordForm = /** @class */ (function (_super) {
14913
15161
  __extends(PasswordForm, _super);
14914
15162
  function PasswordForm() {
14915
15163
  return _super.call(this, {
14916
15164
  password: new forms.FormControl(null, [forms.Validators.required, passwordValidator()]),
14917
15165
  confirm: new forms.FormControl(null, forms.Validators.required),
14918
- }, {}, passwordMatchValidator('password', 'confirm')) || this;
15166
+ }, { password: null, confirm: null }, passwordMatchValidator('password', 'confirm')) || this;
14919
15167
  }
14920
15168
  return PasswordForm;
14921
15169
  }(AbstractForm));
@@ -14929,7 +15177,6 @@
14929
15177
  lastName: new forms.FormControl('', [forms.Validators.required]),
14930
15178
  email: new forms.FormControl('', [forms.Validators.required, forms.Validators.email]),
14931
15179
  password: new PasswordForm(),
14932
- acceptTerms: new forms.FormControl(false, [forms.Validators.requiredTrue]),
14933
15180
  referenceCode: new forms.FormControl(referenceCode)
14934
15181
  }) || this;
14935
15182
  }
@@ -14965,6 +15212,7 @@
14965
15212
  return RegisterFirmForm;
14966
15213
  }(AbstractForm));
14967
15214
 
15215
+ // @TODO Alex: Create a model and handle request fields via class-transformer
14968
15216
  var ResetPasswordForm = /** @class */ (function (_super) {
14969
15217
  __extends(ResetPasswordForm, _super);
14970
15218
  function ResetPasswordForm() {
@@ -15230,7 +15478,7 @@
15230
15478
  __extends(MyTaxIncomeStatementsForm, _super);
15231
15479
  function MyTaxIncomeStatementsForm(incomeStatements, user) {
15232
15480
  var _this = _super.call(this, {
15233
- occupation: new forms.FormControl(user.clientDetails.occupation, [forms.Validators.required, requireSelectValidator()]),
15481
+ occupation: new forms.FormControl(user.clientDetails.occupation, [forms.Validators.required, autocompleteValidator()]),
15234
15482
  allowanceTotalAmount: new forms.FormControl({
15235
15483
  value: incomeStatements.allowanceTotalAmount,
15236
15484
  disabled: true
@@ -15507,14 +15755,12 @@
15507
15755
  exports.BankAccountCalculationService = BankAccountCalculationService;
15508
15756
  exports.BankAccountChartData = BankAccountChartData;
15509
15757
  exports.BankAccountCollection = BankAccountCollection;
15510
- exports.BankAccountForm = BankAccountForm;
15758
+ exports.BankAccountImportForm = BankAccountImportForm;
15511
15759
  exports.BankAccountLoanForm = BankAccountLoanForm;
15512
- exports.BankAccountMigrateForm = BankAccountMigrateForm;
15513
15760
  exports.BankAccountPropertiesForm = BankAccountPropertiesForm;
15514
15761
  exports.BankAccountProperty = BankAccountProperty;
15515
- exports.BankAccountPropertyForm = BankAccountPropertyForm;
15516
15762
  exports.BankAccountService = BankAccountService;
15517
- exports.BankCollection = BankCollection;
15763
+ exports.BankAccountsImportForm = BankAccountsImportForm;
15518
15764
  exports.BankConnection = BankConnection;
15519
15765
  exports.BankConnectionService = BankConnectionService;
15520
15766
  exports.BankLoginData = BankLoginData;
@@ -15583,6 +15829,7 @@
15583
15829
  exports.DepreciationReportItem = DepreciationReportItem;
15584
15830
  exports.DepreciationReportItemCollection = DepreciationReportItemCollection;
15585
15831
  exports.DepreciationService = DepreciationService;
15832
+ exports.Dictionary = Dictionary;
15586
15833
  exports.Document = Document;
15587
15834
  exports.DocumentFolder = DocumentFolder;
15588
15835
  exports.DocumentFolderService = DocumentFolderService;
@@ -15598,6 +15845,7 @@
15598
15845
  exports.ExportDataTable = ExportDataTable;
15599
15846
  exports.ExportFormatterService = ExportFormatterService;
15600
15847
  exports.ExportableCollection = ExportableCollection;
15848
+ exports.FacebookService = FacebookService;
15601
15849
  exports.FinancialYear = FinancialYear;
15602
15850
  exports.Firm = Firm;
15603
15851
  exports.FirmService = FirmService;
@@ -15769,6 +16017,7 @@
15769
16017
  exports.XlsxService = XlsxService;
15770
16018
  exports.atLeastOneCheckedValidator = atLeastOneCheckedValidator;
15771
16019
  exports.atoLinks = atoLinks;
16020
+ exports.autocompleteValidator = autocompleteValidator;
15772
16021
  exports.cloneDeep = cloneDeep;
15773
16022
  exports.compare = compare;
15774
16023
  exports.compareMatOptions = compareMatOptions;
@@ -15779,8 +16028,6 @@
15779
16028
  exports.passwordMatchValidator = passwordMatchValidator;
15780
16029
  exports.passwordValidator = passwordValidator;
15781
16030
  exports.replace = replace;
15782
- exports.requireAutocomplete = requireAutocomplete;
15783
- exports.requireSelectValidator = requireSelectValidator;
15784
16031
  exports.roundTo = roundTo;
15785
16032
  exports.sort = sort;
15786
16033
  exports.sortDeep = sortDeep;