taxtank-core 0.26.0 → 0.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/bundles/taxtank-core.umd.js +561 -408
  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/models/sole/sole-business.js +6 -2
  6. package/esm2015/lib/services/http/depreciation/depreciation-receipt/depreciation-receipt.service.js +40 -0
  7. package/esm2015/lib/services/http/depreciation/depreciation.service.js +61 -22
  8. package/esm2015/lib/services/http/depreciation/index.js +4 -0
  9. package/esm2015/lib/services/http/index.js +2 -1
  10. package/esm2015/lib/services/http/receipt/receipt.service.js +76 -0
  11. package/esm2015/lib/services/http/transaction/transaction-receipt/transaction-receipt.service.js +20 -50
  12. package/esm2015/lib/services/http/transaction/transaction.service.js +12 -11
  13. package/esm2015/lib/services/http/user/index.js +5 -0
  14. package/esm2015/lib/services/http/user/users-invite/users-invite.service.js +23 -0
  15. package/esm2015/public-api.js +2 -3
  16. package/fesm2015/taxtank-core.js +438 -304
  17. package/fesm2015/taxtank-core.js.map +1 -1
  18. package/lib/models/event/app-event-type.enum.d.ts +44 -41
  19. package/lib/models/sole/sole-business.d.ts +5 -1
  20. package/lib/services/http/depreciation/depreciation-receipt/depreciation-receipt.service.d.ts +28 -0
  21. package/lib/services/http/depreciation/depreciation.service.d.ts +15 -7
  22. package/lib/services/http/depreciation/index.d.ts +3 -0
  23. package/lib/services/http/index.d.ts +1 -0
  24. package/lib/services/http/receipt/receipt.service.d.ts +62 -0
  25. package/lib/services/http/transaction/transaction-receipt/transaction-receipt.service.d.ts +21 -21
  26. package/lib/services/http/transaction/transaction.service.d.ts +1 -0
  27. package/lib/services/http/user/index.d.ts +4 -0
  28. package/lib/services/http/user/users-invite/users-invite.service.d.ts +13 -0
  29. package/package.json +1 -1
  30. 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+'),
@@ -3224,6 +3229,96 @@
3224
3229
  classTransformer.Type(function () { return SoleInvoiceTemplate; })
3225
3230
  ], SoleInvoice.prototype, "template", void 0);
3226
3231
 
3232
+ /**
3233
+ * Class contains traveled kilometers and work usage percent in 12 weeks date range
3234
+ * @TODO Vik: Best period: move this and related logic to backend
3235
+ */
3236
+ var LogbookPeriod = /** @class */ (function () {
3237
+ function LogbookPeriod() {
3238
+ }
3239
+ LogbookPeriod.prototype.isEndOfYear = function () {
3240
+ return this.to === new FinancialYear().endDate;
3241
+ };
3242
+ LogbookPeriod.prototype.getWorkUsageByClaim = function (claim) {
3243
+ var claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
3244
+ return Math.round(this.workUsage * (claimKilometers / this.kilometers));
3245
+ };
3246
+ return LogbookPeriod;
3247
+ }());
3248
+ __decorate([
3249
+ classTransformer.Type(function () { return Date; })
3250
+ ], LogbookPeriod.prototype, "from", void 0);
3251
+ __decorate([
3252
+ classTransformer.Type(function () { return Date; })
3253
+ ], LogbookPeriod.prototype, "to", void 0);
3254
+
3255
+ var Vehicle$1 = /** @class */ (function (_super) {
3256
+ __extends(Vehicle, _super);
3257
+ function Vehicle() {
3258
+ return _super !== null && _super.apply(this, arguments) || this;
3259
+ }
3260
+ return Vehicle;
3261
+ }(AbstractModel));
3262
+
3263
+ var VehicleLogbook$1 = /** @class */ (function (_super) {
3264
+ __extends(VehicleLogbook, _super);
3265
+ function VehicleLogbook() {
3266
+ return _super !== null && _super.apply(this, arguments) || this;
3267
+ }
3268
+ return VehicleLogbook;
3269
+ }(AbstractModel));
3270
+
3271
+ var VehicleLogbook = /** @class */ (function (_super) {
3272
+ __extends(VehicleLogbook, _super);
3273
+ function VehicleLogbook() {
3274
+ return _super !== null && _super.apply(this, arguments) || this;
3275
+ }
3276
+ Object.defineProperty(VehicleLogbook.prototype, "kilometers", {
3277
+ get: function () {
3278
+ return this.odometerEnd - this.odometerStart;
3279
+ },
3280
+ enumerable: false,
3281
+ configurable: true
3282
+ });
3283
+ Object.defineProperty(VehicleLogbook.prototype, "tankType", {
3284
+ get: function () {
3285
+ return this.isSoleTank() ? exports.TankTypeEnum.SOLE : exports.TankTypeEnum.WORK;
3286
+ },
3287
+ enumerable: false,
3288
+ configurable: true
3289
+ });
3290
+ VehicleLogbook.prototype.isWorkTank = function () {
3291
+ return !this.business;
3292
+ };
3293
+ VehicleLogbook.prototype.isSoleTank = function () {
3294
+ return !!this.business;
3295
+ };
3296
+ return VehicleLogbook;
3297
+ }(VehicleLogbook$1));
3298
+ /**
3299
+ * 12 weeks in milliseconds
3300
+ * "To work out your business-use percentage, you need to keep a logbook and the odometer readings for the logbook period.
3301
+ * The logbook period is a minimum continuous period of 12 weeks." © Nicole Kelly
3302
+ */
3303
+ VehicleLogbook.periodDuration = 7257600000;
3304
+ __decorate([
3305
+ classTransformer.Type(function () { return Date; })
3306
+ ], VehicleLogbook.prototype, "date", void 0);
3307
+ __decorate([
3308
+ classTransformer.Type(function () { return SoleBusiness; })
3309
+ ], VehicleLogbook.prototype, "business", void 0);
3310
+
3311
+ var Vehicle = /** @class */ (function (_super) {
3312
+ __extends(Vehicle, _super);
3313
+ function Vehicle() {
3314
+ return _super !== null && _super.apply(this, arguments) || this;
3315
+ }
3316
+ return Vehicle;
3317
+ }(Vehicle$1));
3318
+ __decorate([
3319
+ classTransformer.Type(function () { return VehicleLogbook; })
3320
+ ], Vehicle.prototype, "logbook", void 0);
3321
+
3227
3322
  var VehicleClaim$1 = /** @class */ (function (_super) {
3228
3323
  __extends(VehicleClaim, _super);
3229
3324
  function VehicleClaim() {
@@ -4397,6 +4492,10 @@
4397
4492
  };
4398
4493
  return SoleBusiness;
4399
4494
  }(SoleBusiness$1));
4495
+ /**
4496
+ * Maximum number of businesses that a person can have, according to the ATO
4497
+ */
4498
+ SoleBusiness.businessesLimit = 6;
4400
4499
  __decorate([
4401
4500
  classTransformer.Type(function () { return User; })
4402
4501
  ], SoleBusiness.prototype, "user", void 0);
@@ -5985,96 +6084,6 @@
5985
6084
  }]
5986
6085
  }] });
5987
6086
 
5988
- /**
5989
- * Class contains traveled kilometers and work usage percent in 12 weeks date range
5990
- * @TODO Vik: Best period: move this and related logic to backend
5991
- */
5992
- var LogbookPeriod = /** @class */ (function () {
5993
- function LogbookPeriod() {
5994
- }
5995
- LogbookPeriod.prototype.isEndOfYear = function () {
5996
- return this.to === new FinancialYear().endDate;
5997
- };
5998
- LogbookPeriod.prototype.getWorkUsageByClaim = function (claim) {
5999
- var claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
6000
- return Math.round(this.workUsage * (claimKilometers / this.kilometers));
6001
- };
6002
- return LogbookPeriod;
6003
- }());
6004
- __decorate([
6005
- classTransformer.Type(function () { return Date; })
6006
- ], LogbookPeriod.prototype, "from", void 0);
6007
- __decorate([
6008
- classTransformer.Type(function () { return Date; })
6009
- ], LogbookPeriod.prototype, "to", void 0);
6010
-
6011
- var Vehicle$1 = /** @class */ (function (_super) {
6012
- __extends(Vehicle, _super);
6013
- function Vehicle() {
6014
- return _super !== null && _super.apply(this, arguments) || this;
6015
- }
6016
- return Vehicle;
6017
- }(AbstractModel));
6018
-
6019
- var VehicleLogbook$1 = /** @class */ (function (_super) {
6020
- __extends(VehicleLogbook, _super);
6021
- function VehicleLogbook() {
6022
- return _super !== null && _super.apply(this, arguments) || this;
6023
- }
6024
- return VehicleLogbook;
6025
- }(AbstractModel));
6026
-
6027
- var VehicleLogbook = /** @class */ (function (_super) {
6028
- __extends(VehicleLogbook, _super);
6029
- function VehicleLogbook() {
6030
- return _super !== null && _super.apply(this, arguments) || this;
6031
- }
6032
- Object.defineProperty(VehicleLogbook.prototype, "kilometers", {
6033
- get: function () {
6034
- return this.odometerEnd - this.odometerStart;
6035
- },
6036
- enumerable: false,
6037
- configurable: true
6038
- });
6039
- Object.defineProperty(VehicleLogbook.prototype, "tankType", {
6040
- get: function () {
6041
- return this.isSoleTank() ? exports.TankTypeEnum.SOLE : exports.TankTypeEnum.WORK;
6042
- },
6043
- enumerable: false,
6044
- configurable: true
6045
- });
6046
- VehicleLogbook.prototype.isWorkTank = function () {
6047
- return !this.business;
6048
- };
6049
- VehicleLogbook.prototype.isSoleTank = function () {
6050
- return !!this.business;
6051
- };
6052
- return VehicleLogbook;
6053
- }(VehicleLogbook$1));
6054
- /**
6055
- * 12 weeks in milliseconds
6056
- * "To work out your business-use percentage, you need to keep a logbook and the odometer readings for the logbook period.
6057
- * The logbook period is a minimum continuous period of 12 weeks." © Nicole Kelly
6058
- */
6059
- VehicleLogbook.periodDuration = 7257600000;
6060
- __decorate([
6061
- classTransformer.Type(function () { return Date; })
6062
- ], VehicleLogbook.prototype, "date", void 0);
6063
- __decorate([
6064
- classTransformer.Type(function () { return SoleBusiness; })
6065
- ], VehicleLogbook.prototype, "business", void 0);
6066
-
6067
- var Vehicle = /** @class */ (function (_super) {
6068
- __extends(Vehicle, _super);
6069
- function Vehicle() {
6070
- return _super !== null && _super.apply(this, arguments) || this;
6071
- }
6072
- return Vehicle;
6073
- }(Vehicle$1));
6074
- __decorate([
6075
- classTransformer.Type(function () { return VehicleLogbook; })
6076
- ], Vehicle.prototype, "logbook", void 0);
6077
-
6078
6087
  var VehicleClaimCollection = /** @class */ (function (_super) {
6079
6088
  __extends(VehicleClaimCollection, _super);
6080
6089
  function VehicleClaimCollection() {
@@ -11259,67 +11268,198 @@
11259
11268
  }] });
11260
11269
 
11261
11270
  /**
11262
- * Service for logbook best period calculation
11263
- * @TODO Vik: improve structure for such cases (TT-2043)
11264
- * @TODO Vik: Best period move this and related logic to backend
11271
+ * Service that works with Occupations
11265
11272
  */
11266
- var LogbookBestPeriodService = /** @class */ (function () {
11267
- function LogbookBestPeriodService(vehicleClaimDetailsService, vehicleClaimService, vehicleLogbookService, eventDispatcherService) {
11268
- this.vehicleClaimDetailsService = vehicleClaimDetailsService;
11269
- this.vehicleClaimService = vehicleClaimService;
11270
- this.vehicleLogbookService = vehicleLogbookService;
11271
- this.eventDispatcherService = eventDispatcherService;
11272
- this.cacheSubject = new rxjs.ReplaySubject();
11273
- this.listenEvents();
11273
+ var OccupationService = /** @class */ (function () {
11274
+ function OccupationService(http, environment) {
11275
+ this.http = http;
11276
+ this.environment = environment;
11277
+ this.occupationsSubject = new rxjs.ReplaySubject(1);
11274
11278
  }
11275
- LogbookBestPeriodService.prototype.listenEvents = function () {
11276
- this.listenCacheUpdates();
11277
- };
11278
- LogbookBestPeriodService.prototype.get = function () {
11279
- var _this = this;
11280
- if (!this.cache) {
11281
- rxjs.combineLatest([
11282
- this.vehicleClaimDetailsService.get(),
11283
- this.vehicleLogbookService.get().pipe(operators.map(function (logbooks) { return new VehicleLogbookCollection(logbooks); }))
11284
- ])
11285
- .subscribe(function (_a) {
11286
- var _b = __read(_a, 2), details = _b[0], logbooks = _b[1];
11287
- var period;
11288
- // calculate current initial best period
11289
- if ((details === null || details === void 0 ? void 0 : details.isManual) || !(details === null || details === void 0 ? void 0 : details.isLogbookMethod()) || !logbooks.isBestPeriodExist()) {
11290
- period = null;
11291
- }
11292
- else {
11293
- period = logbooks.getBestPeriod();
11294
- }
11295
- // update cache only when best period changed
11296
- if (!isEqual__default["default"](_this.cache, period)) {
11297
- _this.cache = period;
11298
- _this.cacheSubject.next(_this.cache);
11299
- }
11300
- });
11301
- }
11302
- return this.cacheSubject.asObservable();
11303
- };
11304
11279
  /**
11305
- * Dispatch event when logbook best period changed
11280
+ * Get list of occupations
11306
11281
  */
11307
- LogbookBestPeriodService.prototype.listenCacheUpdates = function () {
11282
+ OccupationService.prototype.getOccupations = function () {
11308
11283
  var _this = this;
11309
- // Skip initial calculation and fire event only when subject changed
11310
- this.cacheSubject
11311
- .pipe(operators.skip(1))
11312
- .subscribe(function (period) {
11313
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED, period));
11314
- });
11284
+ if (!this._occupations) {
11285
+ this.http.get(this.environment.apiV2 + "/occupations")
11286
+ .pipe(operators.map(function (response) {
11287
+ return response.map(function (item) { return classTransformer.plainToClass(Occupation, item); });
11288
+ }))
11289
+ .subscribe(function (occupations) {
11290
+ _this._occupations = occupations;
11291
+ _this.occupationsSubject.next(occupations);
11292
+ });
11293
+ }
11294
+ return this.occupationsSubject.asObservable();
11315
11295
  };
11316
- return LogbookBestPeriodService;
11296
+ return OccupationService;
11317
11297
  }());
11318
- LogbookBestPeriodService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LogbookBestPeriodService, deps: [{ token: VehicleClaimDetailsService }, { token: VehicleClaimService }, { token: VehicleLogbookService }, { token: EventDispatcherService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11319
- LogbookBestPeriodService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LogbookBestPeriodService, providedIn: 'root' });
11320
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LogbookBestPeriodService, decorators: [{
11321
- type: i0.Injectable,
11322
- args: [{
11298
+ 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 });
11299
+ OccupationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, providedIn: 'root' });
11300
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: OccupationService, decorators: [{
11301
+ type: i0.Injectable,
11302
+ args: [{
11303
+ providedIn: 'root'
11304
+ }]
11305
+ }], ctorParameters: function () {
11306
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
11307
+ type: i0.Inject,
11308
+ args: ['environment']
11309
+ }] }];
11310
+ } });
11311
+
11312
+ var UserEventSettingService = /** @class */ (function (_super) {
11313
+ __extends(UserEventSettingService, _super);
11314
+ function UserEventSettingService() {
11315
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11316
+ _this.modelClass = UserEventSetting;
11317
+ _this.url = 'user-event-settings';
11318
+ _this.isHydra = true;
11319
+ return _this;
11320
+ }
11321
+ /**
11322
+ * Send batch to add/updated settings
11323
+ */
11324
+ UserEventSettingService.prototype.saveBatch = function (settings) {
11325
+ var _this = this;
11326
+ // batch with post/put requests based on setting id
11327
+ var batch = settings.map(function (setting) {
11328
+ setting.isUpdating = true;
11329
+ if (setting.id) {
11330
+ return _this.http.put(_this.environment.apiV2 + "/" + _this.url + "/" + setting.id, classTransformer.classToPlain(setting));
11331
+ }
11332
+ return _this.http.post(_this.environment.apiV2 + "/" + _this.url, classTransformer.classToPlain(setting));
11333
+ });
11334
+ return rxjs.forkJoin(batch).pipe(operators.map(function (eventSettings) {
11335
+ eventSettings.forEach(function (eventSetting) {
11336
+ // get setting from cache by saved setting id
11337
+ var cachedSetting = _this.cache.find(function (setting) { return setting.id === eventSetting.id; });
11338
+ if (cachedSetting) {
11339
+ replace(_this.cache, eventSetting);
11340
+ }
11341
+ else {
11342
+ _this.cache.push(classTransformer.plainToClass(UserEventSetting, eventSetting));
11343
+ }
11344
+ });
11345
+ _this.updateCache();
11346
+ }));
11347
+ };
11348
+ return UserEventSettingService;
11349
+ }(RestService));
11350
+ 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 });
11351
+ UserEventSettingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, providedIn: 'root' });
11352
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventSettingService, decorators: [{
11353
+ type: i0.Injectable,
11354
+ args: [{
11355
+ providedIn: 'root'
11356
+ }]
11357
+ }] });
11358
+
11359
+ var UserEventTypeService = /** @class */ (function (_super) {
11360
+ __extends(UserEventTypeService, _super);
11361
+ function UserEventTypeService() {
11362
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11363
+ _this.modelClass = UserEventType;
11364
+ _this.url = 'user-event-types';
11365
+ _this.isHydra = true;
11366
+ return _this;
11367
+ }
11368
+ return UserEventTypeService;
11369
+ }(RestService));
11370
+ 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 });
11371
+ UserEventTypeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, providedIn: 'root' });
11372
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserEventTypeService, decorators: [{
11373
+ type: i0.Injectable,
11374
+ args: [{
11375
+ providedIn: 'root'
11376
+ }]
11377
+ }] });
11378
+
11379
+ /**
11380
+ * Service to work with invitations for unregistered users
11381
+ */
11382
+ var UsersInviteService = /** @class */ (function (_super) {
11383
+ __extends(UsersInviteService, _super);
11384
+ function UsersInviteService() {
11385
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11386
+ _this.modelClass = RegistrationInvite;
11387
+ _this.url = 'users/invite';
11388
+ return _this;
11389
+ }
11390
+ return UsersInviteService;
11391
+ }(RestService));
11392
+ 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 });
11393
+ UsersInviteService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UsersInviteService, providedIn: 'root' });
11394
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UsersInviteService, decorators: [{
11395
+ type: i0.Injectable,
11396
+ args: [{
11397
+ providedIn: 'root'
11398
+ }]
11399
+ }] });
11400
+
11401
+ /**
11402
+ * Service for logbook best period calculation
11403
+ * @TODO Vik: improve structure for such cases (TT-2043)
11404
+ * @TODO Vik: Best period move this and related logic to backend
11405
+ */
11406
+ var LogbookBestPeriodService = /** @class */ (function () {
11407
+ function LogbookBestPeriodService(vehicleClaimDetailsService, vehicleClaimService, vehicleLogbookService, eventDispatcherService) {
11408
+ this.vehicleClaimDetailsService = vehicleClaimDetailsService;
11409
+ this.vehicleClaimService = vehicleClaimService;
11410
+ this.vehicleLogbookService = vehicleLogbookService;
11411
+ this.eventDispatcherService = eventDispatcherService;
11412
+ this.cacheSubject = new rxjs.ReplaySubject();
11413
+ this.listenEvents();
11414
+ }
11415
+ LogbookBestPeriodService.prototype.listenEvents = function () {
11416
+ this.listenCacheUpdates();
11417
+ };
11418
+ LogbookBestPeriodService.prototype.get = function () {
11419
+ var _this = this;
11420
+ if (!this.cache) {
11421
+ rxjs.combineLatest([
11422
+ this.vehicleClaimDetailsService.get(),
11423
+ this.vehicleLogbookService.get().pipe(operators.map(function (logbooks) { return new VehicleLogbookCollection(logbooks); }))
11424
+ ])
11425
+ .subscribe(function (_a) {
11426
+ var _b = __read(_a, 2), details = _b[0], logbooks = _b[1];
11427
+ var period;
11428
+ // calculate current initial best period
11429
+ if ((details === null || details === void 0 ? void 0 : details.isManual) || !(details === null || details === void 0 ? void 0 : details.isLogbookMethod()) || !logbooks.isBestPeriodExist()) {
11430
+ period = null;
11431
+ }
11432
+ else {
11433
+ period = logbooks.getBestPeriod();
11434
+ }
11435
+ // update cache only when best period changed
11436
+ if (!isEqual__default["default"](_this.cache, period)) {
11437
+ _this.cache = period;
11438
+ _this.cacheSubject.next(_this.cache);
11439
+ }
11440
+ });
11441
+ }
11442
+ return this.cacheSubject.asObservable();
11443
+ };
11444
+ /**
11445
+ * Dispatch event when logbook best period changed
11446
+ */
11447
+ LogbookBestPeriodService.prototype.listenCacheUpdates = function () {
11448
+ var _this = this;
11449
+ // Skip initial calculation and fire event only when subject changed
11450
+ this.cacheSubject
11451
+ .pipe(operators.skip(1))
11452
+ .subscribe(function (period) {
11453
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED, period));
11454
+ });
11455
+ };
11456
+ return LogbookBestPeriodService;
11457
+ }());
11458
+ LogbookBestPeriodService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LogbookBestPeriodService, deps: [{ token: VehicleClaimDetailsService }, { token: VehicleClaimService }, { token: VehicleLogbookService }, { token: EventDispatcherService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11459
+ LogbookBestPeriodService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LogbookBestPeriodService, providedIn: 'root' });
11460
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: LogbookBestPeriodService, decorators: [{
11461
+ type: i0.Injectable,
11462
+ args: [{
11323
11463
  providedIn: 'root'
11324
11464
  }]
11325
11465
  }], ctorParameters: function () { return [{ type: VehicleClaimDetailsService }, { type: VehicleClaimService }, { type: VehicleLogbookService }, { type: EventDispatcherService }]; } });
@@ -11876,62 +12016,104 @@
11876
12016
  return list;
11877
12017
  }
11878
12018
 
11879
- var TransactionReceiptService = /** @class */ (function () {
11880
- function TransactionReceiptService(http, eventDispatcherService, environment) {
12019
+ /**
12020
+ * Abstract service class to work with transactions-like receipt files (transactions, depreciations, e.t.c.)
12021
+ * @Todo TT-2191 refactor service when receipts API will be updated
12022
+ */
12023
+ var ReceiptService = /** @class */ (function () {
12024
+ function ReceiptService(http, eventDispatcherService, environment, toastService) {
11881
12025
  this.http = http;
11882
12026
  this.eventDispatcherService = eventDispatcherService;
11883
12027
  this.environment = environment;
11884
- this.url = 'receipts';
11885
- this.listenEvents();
12028
+ this.toastService = toastService;
11886
12029
  }
12030
+ ReceiptService.prototype.listenEvents = function () {
12031
+ this.listenParentWithReceiptUpdated();
12032
+ this.listenParentWithoutReceiptUpdated();
12033
+ };
11887
12034
  /**
11888
- * Transaction instance is necessary to take the ID and the receipt file from it.
12035
+ * Entity is necessary to take the ID and the receipt file from it.
11889
12036
  */
11890
- TransactionReceiptService.prototype.add = function (transaction) {
12037
+ ReceiptService.prototype.add = function (receiptEntity) {
11891
12038
  var _this = this;
11892
12039
  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
- });
12040
+ formData.append('file', receiptEntity.file);
12041
+ return this.http.post(this.environment.apiV2 + "/" + this.entityType + "/" + receiptEntity.id + "/receipts", formData)
12042
+ .pipe(operators.map(function (receipt) {
12043
+ var uploadedReceipt = _this.createModelInstance(receipt);
12044
+ _this.eventDispatcherService.dispatch(new AppEvent(_this.receiptCreatedEvent, uploadedReceipt));
12045
+ return uploadedReceipt;
12046
+ }));
11898
12047
  };
11899
- /**
11900
- * Transaction instance is necessary to take the ID and the receipt ID from it.
11901
- */
11902
- TransactionReceiptService.prototype.delete = function (transaction) {
12048
+ ReceiptService.prototype.delete = function (receiptEntity) {
11903
12049
  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();
12050
+ return this.http.delete(this.environment.apiV2 + "/" + this.entityType + "/" + receiptEntity.id + "/receipts/" + receiptEntity.receipt.id)
12051
+ .pipe(operators.map(function () {
12052
+ _this.eventDispatcherService.dispatch(new AppEvent(_this.receiptDeletedEvent, receiptEntity));
12053
+ }));
11912
12054
  };
11913
- TransactionReceiptService.prototype.listenTransactionWithReceiptUpdated = function () {
12055
+ /**
12056
+ * Parent entity was updated with attached receipt
12057
+ */
12058
+ ReceiptService.prototype.listenParentWithReceiptUpdated = function () {
11914
12059
  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);
12060
+ this.eventDispatcherService.on(this.entityUpdatedWithReceiptEvent)
12061
+ .subscribe(function (receiptEntity) {
12062
+ _this.add(receiptEntity).subscribe();
11920
12063
  });
11921
12064
  };
11922
12065
  /**
11923
- * Case when transaction was updated, but receipt was removed
12066
+ * Parent entity was updated, but receipt was removed
11924
12067
  */
11925
- TransactionReceiptService.prototype.listenTransactionWithoutReceiptUpdated = function () {
12068
+ ReceiptService.prototype.listenParentWithoutReceiptUpdated = function () {
11926
12069
  var _this = this;
11927
- this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_DELETED_RECEIPT)
11928
- .subscribe(function (transaction) {
11929
- _this.delete(transaction);
12070
+ this.eventDispatcherService.on(this.entityUpdatedWithDeletedReceiptEvent)
12071
+ .subscribe(function (receiptEntity) {
12072
+ _this.delete(receiptEntity).subscribe();
11930
12073
  });
11931
12074
  };
11932
- return TransactionReceiptService;
12075
+ ReceiptService.prototype.createModelInstance = function (data) {
12076
+ return classTransformer.plainToClass(this.modelClass, data);
12077
+ };
12078
+ return ReceiptService;
11933
12079
  }());
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 });
12080
+ 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 });
12081
+ ReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ReceiptService, providedIn: 'root' });
12082
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ReceiptService, decorators: [{
12083
+ type: i0.Injectable,
12084
+ args: [{
12085
+ providedIn: 'root'
12086
+ }]
12087
+ }], ctorParameters: function () {
12088
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12089
+ type: i0.Inject,
12090
+ args: ['environment']
12091
+ }] }, { type: ToastService }];
12092
+ } });
12093
+
12094
+ /**
12095
+ * @Todo TT-2191 refactor service when receipts API will be updated
12096
+ */
12097
+ var TransactionReceiptService = /** @class */ (function (_super) {
12098
+ __extends(TransactionReceiptService, _super);
12099
+ function TransactionReceiptService(http, eventDispatcherService, environment, toastService) {
12100
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
12101
+ _this.http = http;
12102
+ _this.eventDispatcherService = eventDispatcherService;
12103
+ _this.environment = environment;
12104
+ _this.toastService = toastService;
12105
+ _this.modelClass = TransactionReceipt;
12106
+ _this.entityType = exports.AssetEntityTypeEnum.TRANSACTIONS;
12107
+ _this.receiptCreatedEvent = exports.AppEventTypeEnum.TRANSACTION_RECEIPT_CREATED;
12108
+ _this.receiptDeletedEvent = exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED;
12109
+ _this.entityUpdatedWithReceiptEvent = exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT;
12110
+ _this.entityUpdatedWithDeletedReceiptEvent = exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_DELETED_RECEIPT;
12111
+ _this.listenEvents();
12112
+ return _this;
12113
+ }
12114
+ return TransactionReceiptService;
12115
+ }(ReceiptService));
12116
+ 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
12117
  TransactionReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, providedIn: 'root' });
11936
12118
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, decorators: [{
11937
12119
  type: i0.Injectable,
@@ -11942,7 +12124,7 @@
11942
12124
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11943
12125
  type: i0.Inject,
11944
12126
  args: ['environment']
11945
- }] }];
12127
+ }] }, { type: ToastService }];
11946
12128
  } });
11947
12129
 
11948
12130
  /**
@@ -12066,10 +12248,10 @@
12066
12248
  transactions.forEach(function (transaction, index) {
12067
12249
  // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
12068
12250
  // check if passed receipt and upload file
12069
- if (transaction.file && (transaction.file instanceof File)) {
12251
+ if (transaction.file) {
12070
12252
  transaction.id = response[index].id;
12071
12253
  addedTransactions[index].file = transaction.file;
12072
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_CREATED_WITH_NEW_RECEIPT, addedTransactions[index]));
12254
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT, addedTransactions[index]));
12073
12255
  }
12074
12256
  // @TODO Viktor: implement API for saving of nested transactions
12075
12257
  // add child transactions if exist
@@ -12103,9 +12285,9 @@
12103
12285
  var updatedTransaction = classTransformer.plainToClass(Transaction, response);
12104
12286
  // @TODO need to upload file in the same backend endpoint with transaction add/update
12105
12287
  // check if passed new receipt and upload file
12106
- if (transaction.file && (transaction.file instanceof File)) {
12288
+ if (transaction.file) {
12107
12289
  updatedTransaction.file = transaction.file;
12108
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_NEW_RECEIPT, updatedTransaction));
12290
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT, updatedTransaction));
12109
12291
  // receipt file was removed from form - we should delete receipt from transaction
12110
12292
  }
12111
12293
  else if (!transaction.file && transaction.receipt) {
@@ -12129,8 +12311,7 @@
12129
12311
  _this.addBatch(childTransactionsToAdd).subscribe();
12130
12312
  }
12131
12313
  }
12132
- replace(_this.cache, updatedTransaction);
12133
- _this.updateCache();
12314
+ _this.replaceInCache(updatedTransaction);
12134
12315
  return updatedTransaction;
12135
12316
  }));
12136
12317
  };
@@ -12249,8 +12430,7 @@
12249
12430
  // we don't need to keep file after save
12250
12431
  transactionToUpdate.file = null;
12251
12432
  transactionToUpdate.receipt = transactionReceipt;
12252
- replace(_this.cache, transactionToUpdate);
12253
- _this.updateCache();
12433
+ _this.replaceInCache(transactionToUpdate);
12254
12434
  });
12255
12435
  };
12256
12436
  TransactionService.prototype.listenReceiptDeleted = function () {
@@ -12258,8 +12438,7 @@
12258
12438
  this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED).subscribe(function (transaction) {
12259
12439
  var transactionToUpdate = _this.find(transaction.id);
12260
12440
  transactionToUpdate.receipt = null;
12261
- replace(_this.cache, transactionToUpdate);
12262
- _this.updateCache();
12441
+ _this.replaceInCache(transactionToUpdate);
12263
12442
  });
12264
12443
  };
12265
12444
  TransactionService.prototype.listenVehicleClaimChanges = function () {
@@ -12273,6 +12452,10 @@
12273
12452
  _this.resetCache();
12274
12453
  });
12275
12454
  };
12455
+ TransactionService.prototype.replaceInCache = function (transactionToReplace) {
12456
+ replace(this.cache, transactionToReplace);
12457
+ this.updateCache();
12458
+ };
12276
12459
  return TransactionService;
12277
12460
  }(RestService));
12278
12461
  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 +13630,50 @@
13447
13630
  } });
13448
13631
 
13449
13632
  /**
13450
- * Service for work with DepreciationCapitalProjects
13633
+ * @Todo TT-2191 refactor service when receipts API will be updated
13451
13634
  */
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);
13635
+ var DepreciationReceiptService = /** @class */ (function (_super) {
13636
+ __extends(DepreciationReceiptService, _super);
13637
+ function DepreciationReceiptService(http, eventDispatcherService, environment, toastService) {
13638
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
13639
+ _this.http = http;
13640
+ _this.eventDispatcherService = eventDispatcherService;
13641
+ _this.environment = environment;
13642
+ _this.toastService = toastService;
13643
+ _this.modelClass = DepreciationReceipt;
13644
+ _this.entityType = exports.AssetEntityTypeEnum.DEPRECIATIONS;
13645
+ _this.receiptCreatedEvent = exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_CREATED;
13646
+ _this.receiptDeletedEvent = exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_DELETED;
13647
+ _this.entityUpdatedWithDeletedReceiptEvent = exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT;
13648
+ _this.entityUpdatedWithReceiptEvent = exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT;
13649
+ _this.listenEvents();
13650
+ return _this;
13457
13651
  }
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: [{
13652
+ return DepreciationReceiptService;
13653
+ }(ReceiptService));
13654
+ 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 });
13655
+ DepreciationReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationReceiptService, providedIn: 'root' });
13656
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationReceiptService, decorators: [{
13499
13657
  type: i0.Injectable,
13500
13658
  args: [{
13501
13659
  providedIn: 'root'
13502
13660
  }]
13503
13661
  }], ctorParameters: function () {
13504
- return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
13662
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13505
13663
  type: i0.Inject,
13506
13664
  args: ['environment']
13507
- }] }];
13665
+ }] }, { type: ToastService }];
13508
13666
  } });
13509
13667
 
13510
13668
  var DepreciationService = /** @class */ (function (_super) {
13511
13669
  __extends(DepreciationService, _super);
13512
- function DepreciationService() {
13513
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
13670
+ function DepreciationService(http, eventDispatcherService, environment, toastService, depreciationReceiptService) {
13671
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
13672
+ _this.http = http;
13673
+ _this.eventDispatcherService = eventDispatcherService;
13674
+ _this.environment = environment;
13675
+ _this.toastService = toastService;
13676
+ _this.depreciationReceiptService = depreciationReceiptService;
13514
13677
  _this.modelClass = Depreciation;
13515
13678
  _this.url = 'depreciations';
13516
13679
  return _this;
@@ -13534,15 +13697,42 @@
13534
13697
  DepreciationService.prototype.addBatch = function (depreciations) {
13535
13698
  var _this = this;
13536
13699
  return _super.prototype.addBatch.call(this, depreciations).pipe(operators.map(function (newDepreciations) {
13700
+ depreciations.forEach(function (depreciation, index) {
13701
+ // @TODO backend: need to upload file in the same backend endpoint with depreciation add/update
13702
+ // check if passed receipt and upload file
13703
+ if (depreciation.file && (depreciation.file instanceof File)) {
13704
+ depreciation.id = newDepreciations[index].id;
13705
+ newDepreciations[index].file = depreciation.file;
13706
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT, newDepreciations[index]));
13707
+ }
13708
+ });
13537
13709
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATIONS_CREATED, newDepreciations));
13538
13710
  return newDepreciations;
13539
13711
  }));
13540
13712
  };
13713
+ DepreciationService.prototype.update = function (depreciation) {
13714
+ var _this = this;
13715
+ return _super.prototype.update.call(this, depreciation).pipe(operators.map(function (updatedDepreciation) {
13716
+ // @TODO need to upload file in the same backend endpoint with depreciation add/update
13717
+ // check if passed new receipt and upload file
13718
+ if (depreciation.file && (depreciation.file instanceof File)) {
13719
+ updatedDepreciation.file = depreciation.file;
13720
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT, updatedDepreciation));
13721
+ // receipt file was removed from form - we should delete receipt from transaction
13722
+ }
13723
+ else if (!depreciation.file && depreciation.receipt) {
13724
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT, updatedDepreciation));
13725
+ }
13726
+ return updatedDepreciation;
13727
+ }));
13728
+ };
13541
13729
  /**
13542
13730
  * Listen to Depreciations events
13543
13731
  */
13544
13732
  DepreciationService.prototype.listenEvents = function () {
13545
13733
  this.listenToUpdatedLoan();
13734
+ this.listenReceiptAdded();
13735
+ this.listenReceiptDeleted();
13546
13736
  this.listenVehicleClaimChanges();
13547
13737
  this.listenToUpdatedBankAccount();
13548
13738
  };
@@ -13552,22 +13742,22 @@
13552
13742
  return response || 0;
13553
13743
  }));
13554
13744
  };
13555
- /**
13556
- * Upload depreciation receipt
13557
- * @param depreciation for which will be uploaded receipt
13558
- */
13559
- DepreciationService.prototype.uploadReceipt = function (depreciation) {
13745
+ DepreciationService.prototype.listenReceiptAdded = function () {
13560
13746
  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) {
13747
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_CREATED).subscribe(function (receipt) {
13748
+ var depreciationToUpdate = _this.find(receipt.depreciation.id);
13566
13749
  // 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());
13750
+ depreciationToUpdate.file = null;
13751
+ depreciationToUpdate.receipt = receipt;
13752
+ _this.replaceInCache(depreciationToUpdate);
13753
+ });
13754
+ };
13755
+ DepreciationService.prototype.listenReceiptDeleted = function () {
13756
+ var _this = this;
13757
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_DELETED).subscribe(function (depreciation) {
13758
+ var depreciationToUpdate = _this.find(depreciation.id);
13759
+ depreciationToUpdate.receipt = null;
13760
+ _this.replaceInCache(depreciationToUpdate);
13571
13761
  });
13572
13762
  };
13573
13763
  /**
@@ -13604,16 +13794,86 @@
13604
13794
  _this.resetCache();
13605
13795
  });
13606
13796
  };
13797
+ DepreciationService.prototype.replaceInCache = function (depreciationToReplace) {
13798
+ replace(this.cache, depreciationToReplace);
13799
+ this.updateCache();
13800
+ };
13607
13801
  return DepreciationService;
13608
13802
  }(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 });
13803
+ 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
13804
  DepreciationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, providedIn: 'root' });
13611
13805
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, decorators: [{
13612
13806
  type: i0.Injectable,
13613
13807
  args: [{
13614
13808
  providedIn: 'root'
13615
13809
  }]
13616
- }] });
13810
+ }], ctorParameters: function () {
13811
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13812
+ type: i0.Inject,
13813
+ args: ['environment']
13814
+ }] }, { type: ToastService }, { type: DepreciationReceiptService }];
13815
+ } });
13816
+
13817
+ /**
13818
+ * Service for work with DepreciationCapitalProjects
13819
+ */
13820
+ var DepreciationCapitalProjectService = /** @class */ (function () {
13821
+ function DepreciationCapitalProjectService(http, environment) {
13822
+ this.http = http;
13823
+ this.environment = environment;
13824
+ this.cacheSubject = new rxjs.ReplaySubject(1);
13825
+ }
13826
+ DepreciationCapitalProjectService.prototype.get = function (propertyId) {
13827
+ var _this = this;
13828
+ this.cacheSubject.next([]);
13829
+ this.http.get(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects")
13830
+ .subscribe(function (capitalProjectsBase) {
13831
+ _this.cache = capitalProjectsBase.map(function (capitalProjectBase) {
13832
+ return classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase);
13833
+ });
13834
+ _this.cacheSubject.next(_this.cache);
13835
+ });
13836
+ return this.cacheSubject.asObservable();
13837
+ };
13838
+ DepreciationCapitalProjectService.prototype.add = function (capitalProject, propertyId) {
13839
+ var _this = this;
13840
+ return this.http.post(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects", capitalProject)
13841
+ .pipe(operators.map(function (capitalProjectBase) {
13842
+ _this.cache.push(classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13843
+ _this.cacheSubject.next(_this.cache);
13844
+ }));
13845
+ };
13846
+ DepreciationCapitalProjectService.prototype.update = function (capitalProject, propertyId) {
13847
+ var _this = this;
13848
+ return this.http.put(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id, capitalProject)
13849
+ .pipe(operators.map(function (capitalProjectBase) {
13850
+ replace(_this.cache, classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13851
+ _this.cacheSubject.next(_this.cache);
13852
+ }));
13853
+ };
13854
+ DepreciationCapitalProjectService.prototype.delete = function (capitalProject, propertyId) {
13855
+ var _this = this;
13856
+ return this.http.delete(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id)
13857
+ .pipe(operators.map(function () {
13858
+ _this.cache = _this.cache.filter(function (item) { return capitalProject.id !== item.id; });
13859
+ _this.cacheSubject.next(_this.cache);
13860
+ }));
13861
+ };
13862
+ return DepreciationCapitalProjectService;
13863
+ }());
13864
+ 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 });
13865
+ DepreciationCapitalProjectService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, providedIn: 'root' });
13866
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, decorators: [{
13867
+ type: i0.Injectable,
13868
+ args: [{
13869
+ providedIn: 'root'
13870
+ }]
13871
+ }], ctorParameters: function () {
13872
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
13873
+ type: i0.Inject,
13874
+ args: ['environment']
13875
+ }] }];
13876
+ } });
13617
13877
 
13618
13878
  /**
13619
13879
  * Service to handle document-folders and depending documents logic
@@ -15573,48 +15833,6 @@
15573
15833
  }]
15574
15834
  }] });
15575
15835
 
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
15836
  /**
15619
15837
  * Service to work with user
15620
15838
  */
@@ -15770,73 +15988,6 @@
15770
15988
  }] }];
15771
15989
  } });
15772
15990
 
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
15991
  /**
15841
15992
  * Service to work with XLSX (generate, download, e.t.c.)
15842
15993
  */
@@ -17505,6 +17656,7 @@
17505
17656
  exports.DepreciationLvpReportItem = DepreciationLvpReportItem;
17506
17657
  exports.DepreciationLvpReportItemCollection = DepreciationLvpReportItemCollection;
17507
17658
  exports.DepreciationReceipt = DepreciationReceipt;
17659
+ exports.DepreciationReceiptService = DepreciationReceiptService;
17508
17660
  exports.DepreciationReportItem = DepreciationReportItem;
17509
17661
  exports.DepreciationReportItemCollection = DepreciationReportItemCollection;
17510
17662
  exports.DepreciationService = DepreciationService;
@@ -17705,6 +17857,7 @@
17705
17857
  exports.UserService = UserService;
17706
17858
  exports.UserSwitcherService = UserSwitcherService;
17707
17859
  exports.UserToRegister = UserToRegister;
17860
+ exports.UsersInviteService = UsersInviteService;
17708
17861
  exports.Vehicle = Vehicle;
17709
17862
  exports.VehicleClaim = VehicleClaim;
17710
17863
  exports.VehicleClaimCollection = VehicleClaimCollection;