taxtank-core 0.25.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/bundles/taxtank-core.umd.js +413 -264
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/models/endpoint/endpoints.const.js +3 -1
  4. package/esm2015/lib/models/event/app-event-type.enum.js +45 -42
  5. package/esm2015/lib/services/http/depreciation/depreciation-receipt/depreciation-receipt.service.js +40 -0
  6. package/esm2015/lib/services/http/depreciation/depreciation.service.js +61 -22
  7. package/esm2015/lib/services/http/depreciation/index.js +4 -0
  8. package/esm2015/lib/services/http/index.js +2 -1
  9. package/esm2015/lib/services/http/receipt/receipt.service.js +76 -0
  10. package/esm2015/lib/services/http/transaction/transaction-receipt/transaction-receipt.service.js +20 -50
  11. package/esm2015/lib/services/http/transaction/transaction.service.js +12 -11
  12. package/esm2015/lib/services/http/user/index.js +5 -0
  13. package/esm2015/lib/services/http/user/users-invite/users-invite.service.js +23 -0
  14. package/esm2015/public-api.js +2 -3
  15. package/fesm2015/taxtank-core.js +375 -245
  16. package/fesm2015/taxtank-core.js.map +1 -1
  17. package/lib/models/event/app-event-type.enum.d.ts +44 -41
  18. package/lib/services/http/depreciation/depreciation-receipt/depreciation-receipt.service.d.ts +28 -0
  19. package/lib/services/http/depreciation/depreciation.service.d.ts +15 -7
  20. package/lib/services/http/depreciation/index.d.ts +3 -0
  21. package/lib/services/http/index.d.ts +1 -0
  22. package/lib/services/http/receipt/receipt.service.d.ts +62 -0
  23. package/lib/services/http/transaction/transaction-receipt/transaction-receipt.service.d.ts +21 -21
  24. package/lib/services/http/transaction/transaction.service.d.ts +1 -0
  25. package/lib/services/http/user/index.d.ts +4 -0
  26. package/lib/services/http/user/users-invite/users-invite.service.d.ts +13 -0
  27. package/package.json +1 -1
  28. package/public-api.d.ts +1 -2
@@ -561,47 +561,50 @@
561
561
  AppEventTypeEnum[AppEventTypeEnum["CURRENT_USER_GET_FAILED"] = 11] = "CURRENT_USER_GET_FAILED";
562
562
  AppEventTypeEnum[AppEventTypeEnum["DEPRECIATION_DELETED"] = 12] = "DEPRECIATION_DELETED";
563
563
  AppEventTypeEnum[AppEventTypeEnum["DEPRECIATIONS_CREATED"] = 13] = "DEPRECIATIONS_CREATED";
564
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_CREATED"] = 14] = "INCOME_SOURCES_CREATED";
565
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_UPDATED"] = 15] = "INCOME_SOURCES_UPDATED";
566
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_CREATED"] = 16] = "INCOME_SOURCES_FORECASTS_CREATED";
567
- AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_UPDATED"] = 17] = "INCOME_SOURCES_FORECASTS_UPDATED";
568
- AppEventTypeEnum[AppEventTypeEnum["LOAN_UPDATED"] = 18] = "LOAN_UPDATED";
569
- AppEventTypeEnum[AppEventTypeEnum["LOAN_PAYOUT_UPDATED"] = 19] = "LOAN_PAYOUT_UPDATED";
570
- AppEventTypeEnum[AppEventTypeEnum["MESSAGE_CREATED"] = 20] = "MESSAGE_CREATED";
571
- AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_CREATED"] = 21] = "MESSAGE_FILE_CREATED";
572
- AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_DELETED"] = 22] = "MESSAGE_FILE_DELETED";
573
- AppEventTypeEnum[AppEventTypeEnum["NOTIFICATION_ADDED"] = 23] = "NOTIFICATION_ADDED";
574
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 24] = "PROPERTY_UPDATED_WITH_DOCUMENT";
575
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 25] = "PROPERTY_DOCUMENT_ADDED";
576
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 26] = "PROPERTY_MOVEMENT_CREATED";
577
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 27] = "PROPERTY_MOVEMENT_UPDATED";
578
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 28] = "PROPERTY_MOVEMENT_DELETED";
579
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 29] = "PROPERTY_SHARE_UPDATED";
580
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_ADDED"] = 30] = "PROPERTY_SALE_ADDED";
581
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_DELETED"] = 31] = "PROPERTY_SALE_DELETED";
582
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 32] = "PROPERTY_SUBSCRIPTION_ADDED";
583
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 33] = "PROPERTY_SUBSCRIPTION_DELETED";
584
- AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 34] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
585
- AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 35] = "SERVICE_SUBSCRIPTION_UPDATED";
586
- AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 36] = "TAX_REVIEW_UPDATED";
587
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 37] = "TRANSACTION_CREATED";
588
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 38] = "TRANSACTION_DELETED";
589
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 39] = "TRANSACTION_UPDATED";
590
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED_WITH_NEW_RECEIPT"] = 40] = "TRANSACTION_CREATED_WITH_NEW_RECEIPT";
591
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_NEW_RECEIPT"] = 41] = "TRANSACTION_UPDATED_WITH_NEW_RECEIPT";
592
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 42] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
593
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 43] = "TRANSACTION_RECEIPT_CREATED";
594
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 44] = "TRANSACTION_RECEIPT_DELETED";
595
- AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 45] = "TRANSACTIONS_CREATED";
596
- AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 46] = "USER_UPDATED";
597
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 47] = "VEHICLE_CLAIM_UPDATED";
598
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 48] = "VEHICLE_CLAIM_CREATED";
599
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 49] = "VEHICLE_CLAIM_DETAILS_UPDATED";
600
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 50] = "VEHICLE_CLAIM_DETAILS_CREATED";
601
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 51] = "VEHICLE_LOGBOOK_CREATED";
602
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 52] = "VEHICLE_LOGBOOK_UPDATED";
603
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 53] = "VEHICLE_LOGBOOK_DELETED";
604
- AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 54] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
564
+ AppEventTypeEnum[AppEventTypeEnum["DEPRECIATION_UPDATED_WITH_RECEIPT"] = 14] = "DEPRECIATION_UPDATED_WITH_RECEIPT";
565
+ AppEventTypeEnum[AppEventTypeEnum["DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT"] = 15] = "DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT";
566
+ AppEventTypeEnum[AppEventTypeEnum["DEPRECIATION_RECEIPT_CREATED"] = 16] = "DEPRECIATION_RECEIPT_CREATED";
567
+ AppEventTypeEnum[AppEventTypeEnum["DEPRECIATION_RECEIPT_DELETED"] = 17] = "DEPRECIATION_RECEIPT_DELETED";
568
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_CREATED"] = 18] = "INCOME_SOURCES_CREATED";
569
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_UPDATED"] = 19] = "INCOME_SOURCES_UPDATED";
570
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_CREATED"] = 20] = "INCOME_SOURCES_FORECASTS_CREATED";
571
+ AppEventTypeEnum[AppEventTypeEnum["INCOME_SOURCES_FORECASTS_UPDATED"] = 21] = "INCOME_SOURCES_FORECASTS_UPDATED";
572
+ AppEventTypeEnum[AppEventTypeEnum["LOAN_UPDATED"] = 22] = "LOAN_UPDATED";
573
+ AppEventTypeEnum[AppEventTypeEnum["LOAN_PAYOUT_UPDATED"] = 23] = "LOAN_PAYOUT_UPDATED";
574
+ AppEventTypeEnum[AppEventTypeEnum["MESSAGE_CREATED"] = 24] = "MESSAGE_CREATED";
575
+ AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_CREATED"] = 25] = "MESSAGE_FILE_CREATED";
576
+ AppEventTypeEnum[AppEventTypeEnum["MESSAGE_FILE_DELETED"] = 26] = "MESSAGE_FILE_DELETED";
577
+ AppEventTypeEnum[AppEventTypeEnum["NOTIFICATION_ADDED"] = 27] = "NOTIFICATION_ADDED";
578
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 28] = "PROPERTY_UPDATED_WITH_DOCUMENT";
579
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 29] = "PROPERTY_DOCUMENT_ADDED";
580
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 30] = "PROPERTY_MOVEMENT_CREATED";
581
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 31] = "PROPERTY_MOVEMENT_UPDATED";
582
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 32] = "PROPERTY_MOVEMENT_DELETED";
583
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 33] = "PROPERTY_SHARE_UPDATED";
584
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_ADDED"] = 34] = "PROPERTY_SALE_ADDED";
585
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_DELETED"] = 35] = "PROPERTY_SALE_DELETED";
586
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 36] = "PROPERTY_SUBSCRIPTION_ADDED";
587
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 37] = "PROPERTY_SUBSCRIPTION_DELETED";
588
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 38] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
589
+ AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 39] = "SERVICE_SUBSCRIPTION_UPDATED";
590
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 40] = "TAX_REVIEW_UPDATED";
591
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 41] = "TRANSACTION_CREATED";
592
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 42] = "TRANSACTION_DELETED";
593
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 43] = "TRANSACTION_UPDATED";
594
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 44] = "TRANSACTION_UPDATED_WITH_RECEIPT";
595
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 45] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
596
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 46] = "TRANSACTION_RECEIPT_CREATED";
597
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 47] = "TRANSACTION_RECEIPT_DELETED";
598
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 48] = "TRANSACTIONS_CREATED";
599
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 49] = "USER_UPDATED";
600
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 50] = "VEHICLE_CLAIM_UPDATED";
601
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 51] = "VEHICLE_CLAIM_CREATED";
602
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 52] = "VEHICLE_CLAIM_DETAILS_UPDATED";
603
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 53] = "VEHICLE_CLAIM_DETAILS_CREATED";
604
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 54] = "VEHICLE_LOGBOOK_CREATED";
605
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 55] = "VEHICLE_LOGBOOK_UPDATED";
606
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 56] = "VEHICLE_LOGBOOK_DELETED";
607
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 57] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
605
608
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
606
609
 
607
610
  var EventDispatcherService = /** @class */ (function () {
@@ -975,6 +978,8 @@
975
978
  DEPRECIATIONS_GET: new Endpoint('GET', '\\/depreciations'),
976
979
  DEPRECIATIONS_POST: new Endpoint('POST', '\\/depreciations'),
977
980
  DEPRECIATIONS_PUT: new Endpoint('PUT', '\\/depreciations\\/\\d+'),
981
+ DEPRECIATION_RECEIPTS_POST: new Endpoint('POST', '\\/depreciations\\/\\d+\\/receipts'),
982
+ DEPRECIATION_RECEIPTS_DELETE: new Endpoint('DELETE', '\\/depreciations\\/\\d+\\/receipts\\/\\d+'),
978
983
  EMPLOYEES_GET: new Endpoint('GET', '\\/employees'),
979
984
  EMPLOYEES_INVITES_GET: new Endpoint('GET', '\\/employees\\/\\invites'),
980
985
  EMPLOYEES_INVITES_DELETE: new Endpoint('DELETE', '\\/employees\\/\\invites\\/\\d+'),
@@ -11258,6 +11263,137 @@
11258
11263
  }]
11259
11264
  }] });
11260
11265
 
11266
+ /**
11267
+ * Service that works with Occupations
11268
+ */
11269
+ var OccupationService = /** @class */ (function () {
11270
+ function OccupationService(http, environment) {
11271
+ this.http = http;
11272
+ this.environment = environment;
11273
+ this.occupationsSubject = new rxjs.ReplaySubject(1);
11274
+ }
11275
+ /**
11276
+ * Get list of occupations
11277
+ */
11278
+ OccupationService.prototype.getOccupations = function () {
11279
+ var _this = this;
11280
+ if (!this._occupations) {
11281
+ this.http.get(this.environment.apiV2 + "/occupations")
11282
+ .pipe(operators.map(function (response) {
11283
+ return response.map(function (item) { return classTransformer.plainToClass(Occupation, item); });
11284
+ }))
11285
+ .subscribe(function (occupations) {
11286
+ _this._occupations = occupations;
11287
+ _this.occupationsSubject.next(occupations);
11288
+ });
11289
+ }
11290
+ return this.occupationsSubject.asObservable();
11291
+ };
11292
+ return OccupationService;
11293
+ }());
11294
+ OccupationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11295
+ OccupationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, providedIn: 'root' });
11296
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, decorators: [{
11297
+ type: i0.Injectable,
11298
+ args: [{
11299
+ providedIn: 'root'
11300
+ }]
11301
+ }], ctorParameters: function () {
11302
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
11303
+ type: i0.Inject,
11304
+ args: ['environment']
11305
+ }] }];
11306
+ } });
11307
+
11308
+ var UserEventSettingService = /** @class */ (function (_super) {
11309
+ __extends(UserEventSettingService, _super);
11310
+ function UserEventSettingService() {
11311
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11312
+ _this.modelClass = UserEventSetting;
11313
+ _this.url = 'user-event-settings';
11314
+ _this.isHydra = true;
11315
+ return _this;
11316
+ }
11317
+ /**
11318
+ * Send batch to add/updated settings
11319
+ */
11320
+ UserEventSettingService.prototype.saveBatch = function (settings) {
11321
+ var _this = this;
11322
+ // batch with post/put requests based on setting id
11323
+ var batch = settings.map(function (setting) {
11324
+ setting.isUpdating = true;
11325
+ if (setting.id) {
11326
+ return _this.http.put(_this.environment.apiV2 + "/" + _this.url + "/" + setting.id, classTransformer.classToPlain(setting));
11327
+ }
11328
+ return _this.http.post(_this.environment.apiV2 + "/" + _this.url, classTransformer.classToPlain(setting));
11329
+ });
11330
+ return rxjs.forkJoin(batch).pipe(operators.map(function (eventSettings) {
11331
+ eventSettings.forEach(function (eventSetting) {
11332
+ // get setting from cache by saved setting id
11333
+ var cachedSetting = _this.cache.find(function (setting) { return setting.id === eventSetting.id; });
11334
+ if (cachedSetting) {
11335
+ replace(_this.cache, eventSetting);
11336
+ }
11337
+ else {
11338
+ _this.cache.push(classTransformer.plainToClass(UserEventSetting, eventSetting));
11339
+ }
11340
+ });
11341
+ _this.updateCache();
11342
+ }));
11343
+ };
11344
+ return UserEventSettingService;
11345
+ }(RestService));
11346
+ UserEventSettingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11347
+ UserEventSettingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, providedIn: 'root' });
11348
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, decorators: [{
11349
+ type: i0.Injectable,
11350
+ args: [{
11351
+ providedIn: 'root'
11352
+ }]
11353
+ }] });
11354
+
11355
+ var UserEventTypeService = /** @class */ (function (_super) {
11356
+ __extends(UserEventTypeService, _super);
11357
+ function UserEventTypeService() {
11358
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11359
+ _this.modelClass = UserEventType;
11360
+ _this.url = 'user-event-types';
11361
+ _this.isHydra = true;
11362
+ return _this;
11363
+ }
11364
+ return UserEventTypeService;
11365
+ }(RestService));
11366
+ UserEventTypeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11367
+ UserEventTypeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, providedIn: 'root' });
11368
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, decorators: [{
11369
+ type: i0.Injectable,
11370
+ args: [{
11371
+ providedIn: 'root'
11372
+ }]
11373
+ }] });
11374
+
11375
+ /**
11376
+ * Service to work with invitations for unregistered users
11377
+ */
11378
+ var UsersInviteService = /** @class */ (function (_super) {
11379
+ __extends(UsersInviteService, _super);
11380
+ function UsersInviteService() {
11381
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11382
+ _this.modelClass = RegistrationInvite;
11383
+ _this.url = 'users/invite';
11384
+ return _this;
11385
+ }
11386
+ return UsersInviteService;
11387
+ }(RestService));
11388
+ UsersInviteService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UsersInviteService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11389
+ UsersInviteService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UsersInviteService, providedIn: 'root' });
11390
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UsersInviteService, decorators: [{
11391
+ type: i0.Injectable,
11392
+ args: [{
11393
+ providedIn: 'root'
11394
+ }]
11395
+ }] });
11396
+
11261
11397
  /**
11262
11398
  * Service for logbook best period calculation
11263
11399
  * @TODO Vik: improve structure for such cases (TT-2043)
@@ -11876,62 +12012,104 @@
11876
12012
  return list;
11877
12013
  }
11878
12014
 
11879
- var TransactionReceiptService = /** @class */ (function () {
11880
- function TransactionReceiptService(http, eventDispatcherService, environment) {
12015
+ /**
12016
+ * Abstract service class to work with transactions-like receipt files (transactions, depreciations, e.t.c.)
12017
+ * @Todo TT-2191 refactor service when receipts API will be updated
12018
+ */
12019
+ var ReceiptService = /** @class */ (function () {
12020
+ function ReceiptService(http, eventDispatcherService, environment, toastService) {
11881
12021
  this.http = http;
11882
12022
  this.eventDispatcherService = eventDispatcherService;
11883
12023
  this.environment = environment;
11884
- this.url = 'receipts';
11885
- this.listenEvents();
12024
+ this.toastService = toastService;
11886
12025
  }
12026
+ ReceiptService.prototype.listenEvents = function () {
12027
+ this.listenParentWithReceiptUpdated();
12028
+ this.listenParentWithoutReceiptUpdated();
12029
+ };
11887
12030
  /**
11888
- * Transaction instance is necessary to take the ID and the receipt file from it.
12031
+ * Entity is necessary to take the ID and the receipt file from it.
11889
12032
  */
11890
- TransactionReceiptService.prototype.add = function (transaction) {
12033
+ ReceiptService.prototype.add = function (receiptEntity) {
11891
12034
  var _this = this;
11892
12035
  var formData = new FormData();
11893
- formData.append('file', transaction.file);
11894
- this.http.post(this.environment.apiV2 + "/transactions/" + transaction.id + "/" + this.url, formData)
11895
- .subscribe(function (receiptResponse) {
11896
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_RECEIPT_CREATED, classTransformer.plainToClass(TransactionReceipt, receiptResponse)));
11897
- });
12036
+ formData.append('file', receiptEntity.file);
12037
+ return this.http.post(this.environment.apiV2 + "/" + this.entityType + "/" + receiptEntity.id + "/receipts", formData)
12038
+ .pipe(operators.map(function (receipt) {
12039
+ var uploadedReceipt = _this.createModelInstance(receipt);
12040
+ _this.eventDispatcherService.dispatch(new AppEvent(_this.receiptCreatedEvent, uploadedReceipt));
12041
+ return uploadedReceipt;
12042
+ }));
11898
12043
  };
11899
- /**
11900
- * Transaction instance is necessary to take the ID and the receipt ID from it.
11901
- */
11902
- TransactionReceiptService.prototype.delete = function (transaction) {
12044
+ ReceiptService.prototype.delete = function (receiptEntity) {
11903
12045
  var _this = this;
11904
- this.http.delete(this.environment.apiV2 + "/transactions/" + transaction.id + "/" + this.url + "/" + transaction.receipt.id)
11905
- .subscribe(function () {
11906
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED, transaction));
11907
- });
11908
- };
11909
- TransactionReceiptService.prototype.listenEvents = function () {
11910
- this.listenTransactionWithReceiptUpdated();
11911
- this.listenTransactionWithoutReceiptUpdated();
12046
+ return this.http.delete(this.environment.apiV2 + "/" + this.entityType + "/" + receiptEntity.id + "/receipts/" + receiptEntity.receipt.id)
12047
+ .pipe(operators.map(function () {
12048
+ _this.eventDispatcherService.dispatch(new AppEvent(_this.receiptDeletedEvent, receiptEntity));
12049
+ }));
11912
12050
  };
11913
- TransactionReceiptService.prototype.listenTransactionWithReceiptUpdated = function () {
12051
+ /**
12052
+ * Parent entity was updated with attached receipt
12053
+ */
12054
+ ReceiptService.prototype.listenParentWithReceiptUpdated = function () {
11914
12055
  var _this = this;
11915
- this.eventDispatcherService.on([
11916
- exports.AppEventTypeEnum.TRANSACTION_CREATED_WITH_NEW_RECEIPT,
11917
- exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_NEW_RECEIPT
11918
- ]).subscribe(function (transaction) {
11919
- _this.add(transaction);
12056
+ this.eventDispatcherService.on(this.entityUpdatedWithReceiptEvent)
12057
+ .subscribe(function (receiptEntity) {
12058
+ _this.add(receiptEntity).subscribe();
11920
12059
  });
11921
12060
  };
11922
12061
  /**
11923
- * Case when transaction was updated, but receipt was removed
12062
+ * Parent entity was updated, but receipt was removed
11924
12063
  */
11925
- TransactionReceiptService.prototype.listenTransactionWithoutReceiptUpdated = function () {
12064
+ ReceiptService.prototype.listenParentWithoutReceiptUpdated = function () {
11926
12065
  var _this = this;
11927
- this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_DELETED_RECEIPT)
11928
- .subscribe(function (transaction) {
11929
- _this.delete(transaction);
12066
+ this.eventDispatcherService.on(this.entityUpdatedWithDeletedReceiptEvent)
12067
+ .subscribe(function (receiptEntity) {
12068
+ _this.delete(receiptEntity).subscribe();
11930
12069
  });
11931
12070
  };
11932
- return TransactionReceiptService;
12071
+ ReceiptService.prototype.createModelInstance = function (data) {
12072
+ return classTransformer.plainToClass(this.modelClass, data);
12073
+ };
12074
+ return ReceiptService;
11933
12075
  }());
11934
- TransactionReceiptService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12076
+ ReceiptService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ReceiptService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
12077
+ ReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ReceiptService, providedIn: 'root' });
12078
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ReceiptService, decorators: [{
12079
+ type: i0.Injectable,
12080
+ args: [{
12081
+ providedIn: 'root'
12082
+ }]
12083
+ }], ctorParameters: function () {
12084
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12085
+ type: i0.Inject,
12086
+ args: ['environment']
12087
+ }] }, { type: ToastService }];
12088
+ } });
12089
+
12090
+ /**
12091
+ * @Todo TT-2191 refactor service when receipts API will be updated
12092
+ */
12093
+ var TransactionReceiptService = /** @class */ (function (_super) {
12094
+ __extends(TransactionReceiptService, _super);
12095
+ function TransactionReceiptService(http, eventDispatcherService, environment, toastService) {
12096
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
12097
+ _this.http = http;
12098
+ _this.eventDispatcherService = eventDispatcherService;
12099
+ _this.environment = environment;
12100
+ _this.toastService = toastService;
12101
+ _this.modelClass = TransactionReceipt;
12102
+ _this.entityType = exports.AssetEntityTypeEnum.TRANSACTIONS;
12103
+ _this.receiptCreatedEvent = exports.AppEventTypeEnum.TRANSACTION_RECEIPT_CREATED;
12104
+ _this.receiptDeletedEvent = exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED;
12105
+ _this.entityUpdatedWithReceiptEvent = exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT;
12106
+ _this.entityUpdatedWithDeletedReceiptEvent = exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_DELETED_RECEIPT;
12107
+ _this.listenEvents();
12108
+ return _this;
12109
+ }
12110
+ return TransactionReceiptService;
12111
+ }(ReceiptService));
12112
+ TransactionReceiptService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11935
12113
  TransactionReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, providedIn: 'root' });
11936
12114
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, decorators: [{
11937
12115
  type: i0.Injectable,
@@ -11942,7 +12120,7 @@
11942
12120
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11943
12121
  type: i0.Inject,
11944
12122
  args: ['environment']
11945
- }] }];
12123
+ }] }, { type: ToastService }];
11946
12124
  } });
11947
12125
 
11948
12126
  /**
@@ -12066,10 +12244,10 @@
12066
12244
  transactions.forEach(function (transaction, index) {
12067
12245
  // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
12068
12246
  // check if passed receipt and upload file
12069
- if (transaction.file && (transaction.file instanceof File)) {
12247
+ if (transaction.file) {
12070
12248
  transaction.id = response[index].id;
12071
12249
  addedTransactions[index].file = transaction.file;
12072
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_CREATED_WITH_NEW_RECEIPT, addedTransactions[index]));
12250
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT, addedTransactions[index]));
12073
12251
  }
12074
12252
  // @TODO Viktor: implement API for saving of nested transactions
12075
12253
  // add child transactions if exist
@@ -12103,9 +12281,9 @@
12103
12281
  var updatedTransaction = classTransformer.plainToClass(Transaction, response);
12104
12282
  // @TODO need to upload file in the same backend endpoint with transaction add/update
12105
12283
  // check if passed new receipt and upload file
12106
- if (transaction.file && (transaction.file instanceof File)) {
12284
+ if (transaction.file) {
12107
12285
  updatedTransaction.file = transaction.file;
12108
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_NEW_RECEIPT, updatedTransaction));
12286
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT, updatedTransaction));
12109
12287
  // receipt file was removed from form - we should delete receipt from transaction
12110
12288
  }
12111
12289
  else if (!transaction.file && transaction.receipt) {
@@ -12129,8 +12307,7 @@
12129
12307
  _this.addBatch(childTransactionsToAdd).subscribe();
12130
12308
  }
12131
12309
  }
12132
- replace(_this.cache, updatedTransaction);
12133
- _this.updateCache();
12310
+ _this.replaceInCache(updatedTransaction);
12134
12311
  return updatedTransaction;
12135
12312
  }));
12136
12313
  };
@@ -12249,8 +12426,7 @@
12249
12426
  // we don't need to keep file after save
12250
12427
  transactionToUpdate.file = null;
12251
12428
  transactionToUpdate.receipt = transactionReceipt;
12252
- replace(_this.cache, transactionToUpdate);
12253
- _this.updateCache();
12429
+ _this.replaceInCache(transactionToUpdate);
12254
12430
  });
12255
12431
  };
12256
12432
  TransactionService.prototype.listenReceiptDeleted = function () {
@@ -12258,8 +12434,7 @@
12258
12434
  this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED).subscribe(function (transaction) {
12259
12435
  var transactionToUpdate = _this.find(transaction.id);
12260
12436
  transactionToUpdate.receipt = null;
12261
- replace(_this.cache, transactionToUpdate);
12262
- _this.updateCache();
12437
+ _this.replaceInCache(transactionToUpdate);
12263
12438
  });
12264
12439
  };
12265
12440
  TransactionService.prototype.listenVehicleClaimChanges = function () {
@@ -12273,6 +12448,10 @@
12273
12448
  _this.resetCache();
12274
12449
  });
12275
12450
  };
12451
+ TransactionService.prototype.replaceInCache = function (transactionToReplace) {
12452
+ replace(this.cache, transactionToReplace);
12453
+ this.updateCache();
12454
+ };
12276
12455
  return TransactionService;
12277
12456
  }(RestService));
12278
12457
  TransactionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: TransactionReceiptService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -13447,70 +13626,50 @@
13447
13626
  } });
13448
13627
 
13449
13628
  /**
13450
- * Service for work with DepreciationCapitalProjects
13629
+ * @Todo TT-2191 refactor service when receipts API will be updated
13451
13630
  */
13452
- var DepreciationCapitalProjectService = /** @class */ (function () {
13453
- function DepreciationCapitalProjectService(http, environment) {
13454
- this.http = http;
13455
- this.environment = environment;
13456
- this.cacheSubject = new rxjs.ReplaySubject(1);
13631
+ var DepreciationReceiptService = /** @class */ (function (_super) {
13632
+ __extends(DepreciationReceiptService, _super);
13633
+ function DepreciationReceiptService(http, eventDispatcherService, environment, toastService) {
13634
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
13635
+ _this.http = http;
13636
+ _this.eventDispatcherService = eventDispatcherService;
13637
+ _this.environment = environment;
13638
+ _this.toastService = toastService;
13639
+ _this.modelClass = DepreciationReceipt;
13640
+ _this.entityType = exports.AssetEntityTypeEnum.DEPRECIATIONS;
13641
+ _this.receiptCreatedEvent = exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_CREATED;
13642
+ _this.receiptDeletedEvent = exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_DELETED;
13643
+ _this.entityUpdatedWithDeletedReceiptEvent = exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT;
13644
+ _this.entityUpdatedWithReceiptEvent = exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT;
13645
+ _this.listenEvents();
13646
+ return _this;
13457
13647
  }
13458
- DepreciationCapitalProjectService.prototype.get = function (propertyId) {
13459
- var _this = this;
13460
- this.cacheSubject.next([]);
13461
- this.http.get(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects")
13462
- .subscribe(function (capitalProjectsBase) {
13463
- _this.cache = capitalProjectsBase.map(function (capitalProjectBase) {
13464
- return classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase);
13465
- });
13466
- _this.cacheSubject.next(_this.cache);
13467
- });
13468
- return this.cacheSubject.asObservable();
13469
- };
13470
- DepreciationCapitalProjectService.prototype.add = function (capitalProject, propertyId) {
13471
- var _this = this;
13472
- return this.http.post(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects", capitalProject)
13473
- .pipe(operators.map(function (capitalProjectBase) {
13474
- _this.cache.push(classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13475
- _this.cacheSubject.next(_this.cache);
13476
- }));
13477
- };
13478
- DepreciationCapitalProjectService.prototype.update = function (capitalProject, propertyId) {
13479
- var _this = this;
13480
- return this.http.put(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id, capitalProject)
13481
- .pipe(operators.map(function (capitalProjectBase) {
13482
- replace(_this.cache, classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13483
- _this.cacheSubject.next(_this.cache);
13484
- }));
13485
- };
13486
- DepreciationCapitalProjectService.prototype.delete = function (capitalProject, propertyId) {
13487
- var _this = this;
13488
- return this.http.delete(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id)
13489
- .pipe(operators.map(function () {
13490
- _this.cache = _this.cache.filter(function (item) { return capitalProject.id !== item.id; });
13491
- _this.cacheSubject.next(_this.cache);
13492
- }));
13493
- };
13494
- return DepreciationCapitalProjectService;
13495
- }());
13496
- DepreciationCapitalProjectService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13497
- DepreciationCapitalProjectService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, providedIn: 'root' });
13498
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, decorators: [{
13648
+ return DepreciationReceiptService;
13649
+ }(ReceiptService));
13650
+ DepreciationReceiptService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationReceiptService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13651
+ DepreciationReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationReceiptService, providedIn: 'root' });
13652
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationReceiptService, decorators: [{
13499
13653
  type: i0.Injectable,
13500
13654
  args: [{
13501
13655
  providedIn: 'root'
13502
13656
  }]
13503
13657
  }], ctorParameters: function () {
13504
- return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
13658
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13505
13659
  type: i0.Inject,
13506
13660
  args: ['environment']
13507
- }] }];
13661
+ }] }, { type: ToastService }];
13508
13662
  } });
13509
13663
 
13510
13664
  var DepreciationService = /** @class */ (function (_super) {
13511
13665
  __extends(DepreciationService, _super);
13512
- function DepreciationService() {
13513
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
13666
+ function DepreciationService(http, eventDispatcherService, environment, toastService, depreciationReceiptService) {
13667
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
13668
+ _this.http = http;
13669
+ _this.eventDispatcherService = eventDispatcherService;
13670
+ _this.environment = environment;
13671
+ _this.toastService = toastService;
13672
+ _this.depreciationReceiptService = depreciationReceiptService;
13514
13673
  _this.modelClass = Depreciation;
13515
13674
  _this.url = 'depreciations';
13516
13675
  return _this;
@@ -13534,15 +13693,42 @@
13534
13693
  DepreciationService.prototype.addBatch = function (depreciations) {
13535
13694
  var _this = this;
13536
13695
  return _super.prototype.addBatch.call(this, depreciations).pipe(operators.map(function (newDepreciations) {
13696
+ depreciations.forEach(function (depreciation, index) {
13697
+ // @TODO backend: need to upload file in the same backend endpoint with depreciation add/update
13698
+ // check if passed receipt and upload file
13699
+ if (depreciation.file && (depreciation.file instanceof File)) {
13700
+ depreciation.id = newDepreciations[index].id;
13701
+ newDepreciations[index].file = depreciation.file;
13702
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT, newDepreciations[index]));
13703
+ }
13704
+ });
13537
13705
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATIONS_CREATED, newDepreciations));
13538
13706
  return newDepreciations;
13539
13707
  }));
13540
13708
  };
13709
+ DepreciationService.prototype.update = function (depreciation) {
13710
+ var _this = this;
13711
+ return _super.prototype.update.call(this, depreciation).pipe(operators.map(function (updatedDepreciation) {
13712
+ // @TODO need to upload file in the same backend endpoint with depreciation add/update
13713
+ // check if passed new receipt and upload file
13714
+ if (depreciation.file && (depreciation.file instanceof File)) {
13715
+ updatedDepreciation.file = depreciation.file;
13716
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT, updatedDepreciation));
13717
+ // receipt file was removed from form - we should delete receipt from transaction
13718
+ }
13719
+ else if (!depreciation.file && depreciation.receipt) {
13720
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT, updatedDepreciation));
13721
+ }
13722
+ return updatedDepreciation;
13723
+ }));
13724
+ };
13541
13725
  /**
13542
13726
  * Listen to Depreciations events
13543
13727
  */
13544
13728
  DepreciationService.prototype.listenEvents = function () {
13545
13729
  this.listenToUpdatedLoan();
13730
+ this.listenReceiptAdded();
13731
+ this.listenReceiptDeleted();
13546
13732
  this.listenVehicleClaimChanges();
13547
13733
  this.listenToUpdatedBankAccount();
13548
13734
  };
@@ -13552,22 +13738,22 @@
13552
13738
  return response || 0;
13553
13739
  }));
13554
13740
  };
13555
- /**
13556
- * Upload depreciation receipt
13557
- * @param depreciation for which will be uploaded receipt
13558
- */
13559
- DepreciationService.prototype.uploadReceipt = function (depreciation) {
13741
+ DepreciationService.prototype.listenReceiptAdded = function () {
13560
13742
  var _this = this;
13561
- var formData = new FormData();
13562
- formData.append('file', depreciation.file);
13563
- depreciation.receipt = null;
13564
- this.http.post(this.environment.apiV2 + "/" + this.url + "/" + depreciation.id + "/receipts", formData)
13565
- .subscribe(function (receiptResponse) {
13743
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_CREATED).subscribe(function (receipt) {
13744
+ var depreciationToUpdate = _this.find(receipt.depreciation.id);
13566
13745
  // we don't need to keep file after save
13567
- depreciation.file = null;
13568
- depreciation.receipt = classTransformer.plainToClass(DepreciationReceipt, receiptResponse);
13569
- replace(_this.cache, depreciation);
13570
- _this.cacheSubject.next(_this.cache.slice());
13746
+ depreciationToUpdate.file = null;
13747
+ depreciationToUpdate.receipt = receipt;
13748
+ _this.replaceInCache(depreciationToUpdate);
13749
+ });
13750
+ };
13751
+ DepreciationService.prototype.listenReceiptDeleted = function () {
13752
+ var _this = this;
13753
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_DELETED).subscribe(function (depreciation) {
13754
+ var depreciationToUpdate = _this.find(depreciation.id);
13755
+ depreciationToUpdate.receipt = null;
13756
+ _this.replaceInCache(depreciationToUpdate);
13571
13757
  });
13572
13758
  };
13573
13759
  /**
@@ -13604,16 +13790,86 @@
13604
13790
  _this.resetCache();
13605
13791
  });
13606
13792
  };
13793
+ DepreciationService.prototype.replaceInCache = function (depreciationToReplace) {
13794
+ replace(this.cache, depreciationToReplace);
13795
+ this.updateCache();
13796
+ };
13607
13797
  return DepreciationService;
13608
13798
  }(RestService));
13609
- DepreciationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
13799
+ DepreciationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }, { token: ToastService }, { token: DepreciationReceiptService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13610
13800
  DepreciationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, providedIn: 'root' });
13611
13801
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, decorators: [{
13612
13802
  type: i0.Injectable,
13613
13803
  args: [{
13614
13804
  providedIn: 'root'
13615
13805
  }]
13616
- }] });
13806
+ }], ctorParameters: function () {
13807
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13808
+ type: i0.Inject,
13809
+ args: ['environment']
13810
+ }] }, { type: ToastService }, { type: DepreciationReceiptService }];
13811
+ } });
13812
+
13813
+ /**
13814
+ * Service for work with DepreciationCapitalProjects
13815
+ */
13816
+ var DepreciationCapitalProjectService = /** @class */ (function () {
13817
+ function DepreciationCapitalProjectService(http, environment) {
13818
+ this.http = http;
13819
+ this.environment = environment;
13820
+ this.cacheSubject = new rxjs.ReplaySubject(1);
13821
+ }
13822
+ DepreciationCapitalProjectService.prototype.get = function (propertyId) {
13823
+ var _this = this;
13824
+ this.cacheSubject.next([]);
13825
+ this.http.get(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects")
13826
+ .subscribe(function (capitalProjectsBase) {
13827
+ _this.cache = capitalProjectsBase.map(function (capitalProjectBase) {
13828
+ return classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase);
13829
+ });
13830
+ _this.cacheSubject.next(_this.cache);
13831
+ });
13832
+ return this.cacheSubject.asObservable();
13833
+ };
13834
+ DepreciationCapitalProjectService.prototype.add = function (capitalProject, propertyId) {
13835
+ var _this = this;
13836
+ return this.http.post(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects", capitalProject)
13837
+ .pipe(operators.map(function (capitalProjectBase) {
13838
+ _this.cache.push(classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13839
+ _this.cacheSubject.next(_this.cache);
13840
+ }));
13841
+ };
13842
+ DepreciationCapitalProjectService.prototype.update = function (capitalProject, propertyId) {
13843
+ var _this = this;
13844
+ return this.http.put(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id, capitalProject)
13845
+ .pipe(operators.map(function (capitalProjectBase) {
13846
+ replace(_this.cache, classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13847
+ _this.cacheSubject.next(_this.cache);
13848
+ }));
13849
+ };
13850
+ DepreciationCapitalProjectService.prototype.delete = function (capitalProject, propertyId) {
13851
+ var _this = this;
13852
+ return this.http.delete(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id)
13853
+ .pipe(operators.map(function () {
13854
+ _this.cache = _this.cache.filter(function (item) { return capitalProject.id !== item.id; });
13855
+ _this.cacheSubject.next(_this.cache);
13856
+ }));
13857
+ };
13858
+ return DepreciationCapitalProjectService;
13859
+ }());
13860
+ DepreciationCapitalProjectService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
13861
+ DepreciationCapitalProjectService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, providedIn: 'root' });
13862
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, decorators: [{
13863
+ type: i0.Injectable,
13864
+ args: [{
13865
+ providedIn: 'root'
13866
+ }]
13867
+ }], ctorParameters: function () {
13868
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
13869
+ type: i0.Inject,
13870
+ args: ['environment']
13871
+ }] }];
13872
+ } });
13617
13873
 
13618
13874
  /**
13619
13875
  * Service to handle document-folders and depending documents logic
@@ -15573,48 +15829,6 @@
15573
15829
  }]
15574
15830
  }] });
15575
15831
 
15576
- /**
15577
- * Service that works with Occupations
15578
- */
15579
- var OccupationService = /** @class */ (function () {
15580
- function OccupationService(http, environment) {
15581
- this.http = http;
15582
- this.environment = environment;
15583
- this.occupationsSubject = new rxjs.ReplaySubject(1);
15584
- }
15585
- /**
15586
- * Get list of occupations
15587
- */
15588
- OccupationService.prototype.getOccupations = function () {
15589
- var _this = this;
15590
- if (!this._occupations) {
15591
- this.http.get(this.environment.apiV2 + "/occupations")
15592
- .pipe(operators.map(function (response) {
15593
- return response.map(function (item) { return classTransformer.plainToClass(Occupation, item); });
15594
- }))
15595
- .subscribe(function (occupations) {
15596
- _this._occupations = occupations;
15597
- _this.occupationsSubject.next(occupations);
15598
- });
15599
- }
15600
- return this.occupationsSubject.asObservable();
15601
- };
15602
- return OccupationService;
15603
- }());
15604
- OccupationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
15605
- OccupationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, providedIn: 'root' });
15606
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, decorators: [{
15607
- type: i0.Injectable,
15608
- args: [{
15609
- providedIn: 'root'
15610
- }]
15611
- }], ctorParameters: function () {
15612
- return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
15613
- type: i0.Inject,
15614
- args: ['environment']
15615
- }] }];
15616
- } });
15617
-
15618
15832
  /**
15619
15833
  * Service to work with user
15620
15834
  */
@@ -15770,73 +15984,6 @@
15770
15984
  }] }];
15771
15985
  } });
15772
15986
 
15773
- var UserEventSettingService = /** @class */ (function (_super) {
15774
- __extends(UserEventSettingService, _super);
15775
- function UserEventSettingService() {
15776
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
15777
- _this.modelClass = UserEventSetting;
15778
- _this.url = 'user-event-settings';
15779
- _this.isHydra = true;
15780
- return _this;
15781
- }
15782
- /**
15783
- * Send batch to add/updated settings
15784
- */
15785
- UserEventSettingService.prototype.saveBatch = function (settings) {
15786
- var _this = this;
15787
- // batch with post/put requests based on setting id
15788
- var batch = settings.map(function (setting) {
15789
- setting.isUpdating = true;
15790
- if (setting.id) {
15791
- return _this.http.put(_this.environment.apiV2 + "/" + _this.url + "/" + setting.id, classTransformer.classToPlain(setting));
15792
- }
15793
- return _this.http.post(_this.environment.apiV2 + "/" + _this.url, classTransformer.classToPlain(setting));
15794
- });
15795
- return rxjs.forkJoin(batch).pipe(operators.map(function (eventSettings) {
15796
- eventSettings.forEach(function (eventSetting) {
15797
- // get setting from cache by saved setting id
15798
- var cachedSetting = _this.cache.find(function (setting) { return setting.id === eventSetting.id; });
15799
- if (cachedSetting) {
15800
- replace(_this.cache, eventSetting);
15801
- }
15802
- else {
15803
- _this.cache.push(classTransformer.plainToClass(UserEventSetting, eventSetting));
15804
- }
15805
- });
15806
- _this.updateCache();
15807
- }));
15808
- };
15809
- return UserEventSettingService;
15810
- }(RestService));
15811
- UserEventSettingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
15812
- UserEventSettingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, providedIn: 'root' });
15813
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, decorators: [{
15814
- type: i0.Injectable,
15815
- args: [{
15816
- providedIn: 'root'
15817
- }]
15818
- }] });
15819
-
15820
- var UserEventTypeService = /** @class */ (function (_super) {
15821
- __extends(UserEventTypeService, _super);
15822
- function UserEventTypeService() {
15823
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
15824
- _this.modelClass = UserEventType;
15825
- _this.url = 'user-event-types';
15826
- _this.isHydra = true;
15827
- return _this;
15828
- }
15829
- return UserEventTypeService;
15830
- }(RestService));
15831
- UserEventTypeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
15832
- UserEventTypeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, providedIn: 'root' });
15833
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, decorators: [{
15834
- type: i0.Injectable,
15835
- args: [{
15836
- providedIn: 'root'
15837
- }]
15838
- }] });
15839
-
15840
15987
  /**
15841
15988
  * Service to work with XLSX (generate, download, e.t.c.)
15842
15989
  */
@@ -17505,6 +17652,7 @@
17505
17652
  exports.DepreciationLvpReportItem = DepreciationLvpReportItem;
17506
17653
  exports.DepreciationLvpReportItemCollection = DepreciationLvpReportItemCollection;
17507
17654
  exports.DepreciationReceipt = DepreciationReceipt;
17655
+ exports.DepreciationReceiptService = DepreciationReceiptService;
17508
17656
  exports.DepreciationReportItem = DepreciationReportItem;
17509
17657
  exports.DepreciationReportItemCollection = DepreciationReportItemCollection;
17510
17658
  exports.DepreciationService = DepreciationService;
@@ -17705,6 +17853,7 @@
17705
17853
  exports.UserService = UserService;
17706
17854
  exports.UserSwitcherService = UserSwitcherService;
17707
17855
  exports.UserToRegister = UserToRegister;
17856
+ exports.UsersInviteService = UsersInviteService;
17708
17857
  exports.Vehicle = Vehicle;
17709
17858
  exports.VehicleClaim = VehicleClaim;
17710
17859
  exports.VehicleClaimCollection = VehicleClaimCollection;