taxtank-core 0.27.0 → 0.27.3

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 (64) hide show
  1. package/bundles/taxtank-core.umd.js +598 -284
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/depreciation.collection.js +10 -9
  4. package/esm2015/lib/db/Enums/depreciation-calculation.enum.js +2 -2
  5. package/esm2015/lib/db/Enums/sole-depreciation-method.enum.js +6 -0
  6. package/esm2015/lib/db/Models/sole/sole-business-activity.js +4 -0
  7. package/esm2015/lib/db/Models/sole/sole-business.js +1 -1
  8. package/esm2015/lib/db/Models/sole/sole-depreciation-method.js +4 -0
  9. package/esm2015/lib/db/Models/sole/sole-details.js +1 -1
  10. package/esm2015/lib/forms/sole/index.js +2 -1
  11. package/esm2015/lib/forms/sole/sole-business.form.js +3 -3
  12. package/esm2015/lib/forms/sole/sole-depreciation-method.form.js +10 -0
  13. package/esm2015/lib/models/depreciation/depreciation-group.enum.js +2 -1
  14. package/esm2015/lib/models/depreciation/depreciation-groups.const.js +7 -2
  15. package/esm2015/lib/models/depreciation/depreciation.js +32 -25
  16. package/esm2015/lib/models/endpoint/endpoints.const.js +8 -4
  17. package/esm2015/lib/models/event/app-event-type.enum.js +47 -42
  18. package/esm2015/lib/models/report/depreciation/depreciation-report-item.js +2 -2
  19. package/esm2015/lib/models/report/my-tax/my-tax-deductions/my-tax-deductions.js +2 -2
  20. package/esm2015/lib/models/sole/index.js +3 -1
  21. package/esm2015/lib/models/sole/sole-business-activity.js +4 -0
  22. package/esm2015/lib/models/sole/sole-business.js +10 -2
  23. package/esm2015/lib/models/sole/sole-depreciation-method.js +8 -0
  24. package/esm2015/lib/services/http/depreciation/depreciation-receipt/depreciation-receipt.service.js +40 -0
  25. package/esm2015/lib/services/http/depreciation/depreciation.service.js +79 -22
  26. package/esm2015/lib/services/http/depreciation/index.js +4 -0
  27. package/esm2015/lib/services/http/property/property.service.js +8 -1
  28. package/esm2015/lib/services/http/receipt/receipt.service.js +76 -0
  29. package/esm2015/lib/services/http/sole/index.js +3 -1
  30. package/esm2015/lib/services/http/sole/sole-business-activity/sole-business-activity.service.js +21 -0
  31. package/esm2015/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.js +62 -0
  32. package/esm2015/lib/services/http/transaction/transaction-receipt/transaction-receipt.service.js +20 -50
  33. package/esm2015/lib/services/http/transaction/transaction.service.js +12 -11
  34. package/esm2015/public-api.js +3 -3
  35. package/fesm2015/taxtank-core.js +502 -245
  36. package/fesm2015/taxtank-core.js.map +1 -1
  37. package/lib/collections/depreciation.collection.d.ts +2 -1
  38. package/lib/db/Enums/depreciation-calculation.enum.d.ts +2 -2
  39. package/lib/db/Enums/sole-depreciation-method.enum.d.ts +4 -0
  40. package/lib/db/Models/sole/sole-business-activity.d.ts +6 -0
  41. package/lib/db/Models/sole/sole-business.d.ts +2 -1
  42. package/lib/db/Models/sole/sole-depreciation-method.d.ts +10 -0
  43. package/lib/forms/sole/index.d.ts +1 -0
  44. package/lib/forms/sole/sole-business.form.d.ts +1 -1
  45. package/lib/forms/sole/sole-depreciation-method.form.d.ts +5 -0
  46. package/lib/models/depreciation/depreciation-group.enum.d.ts +2 -1
  47. package/lib/models/depreciation/depreciation.d.ts +9 -16
  48. package/lib/models/event/app-event-type.enum.d.ts +46 -41
  49. package/lib/models/sole/index.d.ts +2 -0
  50. package/lib/models/sole/sole-business-activity.d.ts +3 -0
  51. package/lib/models/sole/sole-business.d.ts +7 -1
  52. package/lib/models/sole/sole-depreciation-method.d.ts +4 -0
  53. package/lib/services/http/depreciation/depreciation-receipt/depreciation-receipt.service.d.ts +28 -0
  54. package/lib/services/http/depreciation/depreciation.service.d.ts +23 -7
  55. package/lib/services/http/depreciation/index.d.ts +3 -0
  56. package/lib/services/http/property/property.service.d.ts +1 -0
  57. package/lib/services/http/receipt/receipt.service.d.ts +62 -0
  58. package/lib/services/http/sole/index.d.ts +2 -0
  59. package/lib/services/http/sole/sole-business-activity/sole-business-activity.service.d.ts +11 -0
  60. package/lib/services/http/sole/sole-depreciation-method/sole-depreciation-method.service.d.ts +23 -0
  61. package/lib/services/http/transaction/transaction-receipt/transaction-receipt.service.d.ts +21 -21
  62. package/lib/services/http/transaction/transaction.service.d.ts +1 -0
  63. package/package.json +1 -1
  64. package/public-api.d.ts +2 -2
@@ -561,47 +561,52 @@
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_DEPRECIATION_CALCULATION_UPDATED"] = 28] = "PROPERTY_DEPRECIATION_CALCULATION_UPDATED";
579
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_UPDATED_WITH_DOCUMENT"] = 29] = "PROPERTY_UPDATED_WITH_DOCUMENT";
580
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_DOCUMENT_ADDED"] = 30] = "PROPERTY_DOCUMENT_ADDED";
581
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_CREATED"] = 31] = "PROPERTY_MOVEMENT_CREATED";
582
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_UPDATED"] = 32] = "PROPERTY_MOVEMENT_UPDATED";
583
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_MOVEMENT_DELETED"] = 33] = "PROPERTY_MOVEMENT_DELETED";
584
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SHARE_UPDATED"] = 34] = "PROPERTY_SHARE_UPDATED";
585
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_ADDED"] = 35] = "PROPERTY_SALE_ADDED";
586
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SALE_DELETED"] = 36] = "PROPERTY_SALE_DELETED";
587
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_ADDED"] = 37] = "PROPERTY_SUBSCRIPTION_ADDED";
588
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_SUBSCRIPTION_DELETED"] = 38] = "PROPERTY_SUBSCRIPTION_DELETED";
589
+ AppEventTypeEnum[AppEventTypeEnum["PROPERTY_VALUATION_DOCUMENT_CREATED"] = 39] = "PROPERTY_VALUATION_DOCUMENT_CREATED";
590
+ AppEventTypeEnum[AppEventTypeEnum["SERVICE_SUBSCRIPTION_UPDATED"] = 40] = "SERVICE_SUBSCRIPTION_UPDATED";
591
+ AppEventTypeEnum[AppEventTypeEnum["SOLE_DEPRECIATION_METHOD_UPDATED"] = 41] = "SOLE_DEPRECIATION_METHOD_UPDATED";
592
+ AppEventTypeEnum[AppEventTypeEnum["TAX_REVIEW_UPDATED"] = 42] = "TAX_REVIEW_UPDATED";
593
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_CREATED"] = 43] = "TRANSACTION_CREATED";
594
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_DELETED"] = 44] = "TRANSACTION_DELETED";
595
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED"] = 45] = "TRANSACTION_UPDATED";
596
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_RECEIPT"] = 46] = "TRANSACTION_UPDATED_WITH_RECEIPT";
597
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_UPDATED_WITH_DELETED_RECEIPT"] = 47] = "TRANSACTION_UPDATED_WITH_DELETED_RECEIPT";
598
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_CREATED"] = 48] = "TRANSACTION_RECEIPT_CREATED";
599
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTION_RECEIPT_DELETED"] = 49] = "TRANSACTION_RECEIPT_DELETED";
600
+ AppEventTypeEnum[AppEventTypeEnum["TRANSACTIONS_CREATED"] = 50] = "TRANSACTIONS_CREATED";
601
+ AppEventTypeEnum[AppEventTypeEnum["USER_UPDATED"] = 51] = "USER_UPDATED";
602
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_UPDATED"] = 52] = "VEHICLE_CLAIM_UPDATED";
603
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_CREATED"] = 53] = "VEHICLE_CLAIM_CREATED";
604
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_UPDATED"] = 54] = "VEHICLE_CLAIM_DETAILS_UPDATED";
605
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_CLAIM_DETAILS_CREATED"] = 55] = "VEHICLE_CLAIM_DETAILS_CREATED";
606
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_CREATED"] = 56] = "VEHICLE_LOGBOOK_CREATED";
607
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_UPDATED"] = 57] = "VEHICLE_LOGBOOK_UPDATED";
608
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_DELETED"] = 58] = "VEHICLE_LOGBOOK_DELETED";
609
+ AppEventTypeEnum[AppEventTypeEnum["VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED"] = 59] = "VEHICLE_LOGBOOK_BEST_PERIOD_UPDATED";
605
610
  })(exports.AppEventTypeEnum || (exports.AppEventTypeEnum = {}));
606
611
 
607
612
  var EventDispatcherService = /** @class */ (function () {
@@ -975,6 +980,8 @@
975
980
  DEPRECIATIONS_GET: new Endpoint('GET', '\\/depreciations'),
976
981
  DEPRECIATIONS_POST: new Endpoint('POST', '\\/depreciations'),
977
982
  DEPRECIATIONS_PUT: new Endpoint('PUT', '\\/depreciations\\/\\d+'),
983
+ DEPRECIATION_RECEIPTS_POST: new Endpoint('POST', '\\/depreciations\\/\\d+\\/receipts'),
984
+ DEPRECIATION_RECEIPTS_DELETE: new Endpoint('DELETE', '\\/depreciations\\/\\d+\\/receipts\\/\\d+'),
978
985
  EMPLOYEES_GET: new Endpoint('GET', '\\/employees'),
979
986
  EMPLOYEES_INVITES_GET: new Endpoint('GET', '\\/employees\\/\\invites'),
980
987
  EMPLOYEES_INVITES_DELETE: new Endpoint('DELETE', '\\/employees\\/\\invites\\/\\d+'),
@@ -1049,11 +1056,13 @@
1049
1056
  SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/subscriptions\\/items'),
1050
1057
  SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
1051
1058
  SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
1052
- SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\d+'),
1059
+ SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
1060
+ SOLE_DEPRECIATION_METHODS_GET: new Endpoint('GET', '\\/sole-depreciation-methods'),
1061
+ SOLE_DEPRECIATION_METHODS_PUT: new Endpoint('PUT', '\\/sole-depreciation-methods\\/\\d+'),
1053
1062
  SOLE_INVOICE_TEMPLATES_GET: new Endpoint('GET', '\\/sole-invoice-templates'),
1054
1063
  SOLE_INVOICE_TEMPLATES_POST: new Endpoint('POST', '\\/sole-invoice-templates'),
1055
- SOLE_INVOICE_TEMPLATES_PUT: new Endpoint('PUT', '\\/sole-invoice-templates\\d+'),
1056
- SOLE_INVOICE_TEMPLATES_DELETE: new Endpoint('DELETE', '\\/sole-invoice-templates\\d+'),
1064
+ SOLE_INVOICE_TEMPLATES_PUT: new Endpoint('PUT', '\\/sole-invoice-templates\\/\\d+'),
1065
+ SOLE_INVOICE_TEMPLATES_DELETE: new Endpoint('DELETE', '\\/sole-invoice-templates\\/\\d+'),
1057
1066
  TAX_CALCULATION_POST: new Endpoint('POST', '\\/tax-calculation'),
1058
1067
  TAX_REVIEWS_GET: new Endpoint('GET', '\\/tax-reviews'),
1059
1068
  TAX_REVIEWS_DELETE: new Endpoint('DELETE', '\\/tax-reviews\\/\\d+'),
@@ -3224,6 +3233,96 @@
3224
3233
  classTransformer.Type(function () { return SoleInvoiceTemplate; })
3225
3234
  ], SoleInvoice.prototype, "template", void 0);
3226
3235
 
3236
+ /**
3237
+ * Class contains traveled kilometers and work usage percent in 12 weeks date range
3238
+ * @TODO Vik: Best period: move this and related logic to backend
3239
+ */
3240
+ var LogbookPeriod = /** @class */ (function () {
3241
+ function LogbookPeriod() {
3242
+ }
3243
+ LogbookPeriod.prototype.isEndOfYear = function () {
3244
+ return this.to === new FinancialYear().endDate;
3245
+ };
3246
+ LogbookPeriod.prototype.getWorkUsageByClaim = function (claim) {
3247
+ var claimKilometers = this.logbooks.getByVehicleClaim(claim).getClaimableLogbooks().kilometers;
3248
+ return Math.round(this.workUsage * (claimKilometers / this.kilometers));
3249
+ };
3250
+ return LogbookPeriod;
3251
+ }());
3252
+ __decorate([
3253
+ classTransformer.Type(function () { return Date; })
3254
+ ], LogbookPeriod.prototype, "from", void 0);
3255
+ __decorate([
3256
+ classTransformer.Type(function () { return Date; })
3257
+ ], LogbookPeriod.prototype, "to", void 0);
3258
+
3259
+ var Vehicle$1 = /** @class */ (function (_super) {
3260
+ __extends(Vehicle, _super);
3261
+ function Vehicle() {
3262
+ return _super !== null && _super.apply(this, arguments) || this;
3263
+ }
3264
+ return Vehicle;
3265
+ }(AbstractModel));
3266
+
3267
+ var VehicleLogbook$1 = /** @class */ (function (_super) {
3268
+ __extends(VehicleLogbook, _super);
3269
+ function VehicleLogbook() {
3270
+ return _super !== null && _super.apply(this, arguments) || this;
3271
+ }
3272
+ return VehicleLogbook;
3273
+ }(AbstractModel));
3274
+
3275
+ var VehicleLogbook = /** @class */ (function (_super) {
3276
+ __extends(VehicleLogbook, _super);
3277
+ function VehicleLogbook() {
3278
+ return _super !== null && _super.apply(this, arguments) || this;
3279
+ }
3280
+ Object.defineProperty(VehicleLogbook.prototype, "kilometers", {
3281
+ get: function () {
3282
+ return this.odometerEnd - this.odometerStart;
3283
+ },
3284
+ enumerable: false,
3285
+ configurable: true
3286
+ });
3287
+ Object.defineProperty(VehicleLogbook.prototype, "tankType", {
3288
+ get: function () {
3289
+ return this.isSoleTank() ? exports.TankTypeEnum.SOLE : exports.TankTypeEnum.WORK;
3290
+ },
3291
+ enumerable: false,
3292
+ configurable: true
3293
+ });
3294
+ VehicleLogbook.prototype.isWorkTank = function () {
3295
+ return !this.business;
3296
+ };
3297
+ VehicleLogbook.prototype.isSoleTank = function () {
3298
+ return !!this.business;
3299
+ };
3300
+ return VehicleLogbook;
3301
+ }(VehicleLogbook$1));
3302
+ /**
3303
+ * 12 weeks in milliseconds
3304
+ * "To work out your business-use percentage, you need to keep a logbook and the odometer readings for the logbook period.
3305
+ * The logbook period is a minimum continuous period of 12 weeks." © Nicole Kelly
3306
+ */
3307
+ VehicleLogbook.periodDuration = 7257600000;
3308
+ __decorate([
3309
+ classTransformer.Type(function () { return Date; })
3310
+ ], VehicleLogbook.prototype, "date", void 0);
3311
+ __decorate([
3312
+ classTransformer.Type(function () { return SoleBusiness; })
3313
+ ], VehicleLogbook.prototype, "business", void 0);
3314
+
3315
+ var Vehicle = /** @class */ (function (_super) {
3316
+ __extends(Vehicle, _super);
3317
+ function Vehicle() {
3318
+ return _super !== null && _super.apply(this, arguments) || this;
3319
+ }
3320
+ return Vehicle;
3321
+ }(Vehicle$1));
3322
+ __decorate([
3323
+ classTransformer.Type(function () { return VehicleLogbook; })
3324
+ ], Vehicle.prototype, "logbook", void 0);
3325
+
3227
3326
  var VehicleClaim$1 = /** @class */ (function (_super) {
3228
3327
  __extends(VehicleClaim, _super);
3229
3328
  function VehicleClaim() {
@@ -3422,9 +3521,9 @@
3422
3521
  (function (DepreciationCalculationEnum) {
3423
3522
  DepreciationCalculationEnum[DepreciationCalculationEnum["PRIME_COST"] = 1] = "PRIME_COST";
3424
3523
  DepreciationCalculationEnum[DepreciationCalculationEnum["DIMINISHING"] = 2] = "DIMINISHING";
3425
- DepreciationCalculationEnum[DepreciationCalculationEnum["CAPITAL"] = 3] = "CAPITAL";
3426
3524
  DepreciationCalculationEnum[DepreciationCalculationEnum["LVP"] = 4] = "LVP";
3427
3525
  DepreciationCalculationEnum[DepreciationCalculationEnum["AMORTISATION"] = 5] = "AMORTISATION";
3526
+ DepreciationCalculationEnum[DepreciationCalculationEnum["SBP"] = 6] = "SBP";
3428
3527
  })(exports.DepreciationCalculationEnum || (exports.DepreciationCalculationEnum = {}));
3429
3528
 
3430
3529
  var DepreciationCapitalProject$1 = /** @class */ (function (_super) {
@@ -4219,6 +4318,9 @@
4219
4318
  classTransformer.Type(function () { return Date; })
4220
4319
  ], BankTransaction.prototype, "date", void 0);
4221
4320
 
4321
+ /**
4322
+ * @TODO Alex: clarify grouping rules and refactor
4323
+ */
4222
4324
  var Depreciation = /** @class */ (function (_super) {
4223
4325
  __extends(Depreciation, _super);
4224
4326
  function Depreciation() {
@@ -4231,6 +4333,7 @@
4231
4333
  _this.amount = 0;
4232
4334
  return _this;
4233
4335
  }
4336
+ // Type checking
4234
4337
  Depreciation.prototype.isCapital = function () {
4235
4338
  return this.type === exports.DepreciationTypeEnum.CAPITAL_WORKS;
4236
4339
  };
@@ -4240,30 +4343,9 @@
4240
4343
  Depreciation.prototype.isAsset = function () {
4241
4344
  return this.type === exports.DepreciationTypeEnum.PLANT_EQUIPMENT;
4242
4345
  };
4243
- /**
4244
- * check if depreciation should be displayed in written off category
4245
- * details in project documentation
4246
- * @TODO new FinancialYear(this.writeOffDate) === new FinancialYear()
4247
- */
4248
- Depreciation.prototype.isWrittenOff = function () {
4249
- return this.isAsset && this.writeOffDate && new FinancialYear(this.writeOffDate).year === this.financialYear;
4250
- };
4251
- /**
4252
- * Check if depreciation is Plant & Equipment
4253
- */
4254
- Depreciation.prototype.isPlantEquipment = function () {
4255
- return this.isAsset() && !this.isWrittenOff() && !this.isLowValuePool();
4256
- };
4257
- /**
4258
- * check if depreciation should be displayed in low value pool
4259
- * details in project documentation
4260
- * @TODO new FinancialYear(this.writeOffDate) === new FinancialYear()
4261
- */
4262
- Depreciation.prototype.isLowValuePool = function () {
4263
- return this.isAsset &&
4264
- this.calculation === exports.DepreciationCalculationEnum.DIMINISHING &&
4265
- this.amount > Depreciation.WRITTEN_OFF_THRESHOLD &&
4266
- this.amount <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
4346
+ // Calculation checking
4347
+ Depreciation.prototype.isSBPCalculation = function () {
4348
+ return this.calculation === exports.DepreciationCalculationEnum.SBP;
4267
4349
  };
4268
4350
  Depreciation.prototype.isPrimeCost = function () {
4269
4351
  return this.calculation === exports.DepreciationCalculationEnum.PRIME_COST;
@@ -4271,6 +4353,34 @@
4271
4353
  Depreciation.prototype.isDiminishing = function () {
4272
4354
  return this.calculation === exports.DepreciationCalculationEnum.DIMINISHING;
4273
4355
  };
4356
+ // Pool checking
4357
+ Depreciation.prototype.isPlantEquipmentPool = function () {
4358
+ return this.isAsset() && !this.isSBPCalculation() && !this.isWrittenOff() && !this.isLVP();
4359
+ };
4360
+ Depreciation.prototype.isLVP = function () {
4361
+ return this.isAsset()
4362
+ && !this.isSBPCalculation()
4363
+ && this.isDiminishing()
4364
+ && this.currentYearForecast.closeBalance > Depreciation.WRITTEN_OFF_THRESHOLD
4365
+ && this.currentYearForecast.closeBalance <= Depreciation.LOW_VALUE_POOL_THRESHOLD;
4366
+ };
4367
+ Depreciation.prototype.isSBP = function () {
4368
+ return this.isAsset() && this.isSBPCalculation() && !this.isWrittenOff();
4369
+ };
4370
+ Depreciation.prototype.isWrittenOff = function () {
4371
+ return this.writeOffYear === new FinancialYear().year;
4372
+ };
4373
+ Object.defineProperty(Depreciation.prototype, "writeOffYear", {
4374
+ get: function () {
4375
+ var _a;
4376
+ if (!this.writeOffManualDate && !this.writeOffDate) {
4377
+ return null;
4378
+ }
4379
+ return (_a = new FinancialYear(this.writeOffManualDate || this.writeOffDate)) === null || _a === void 0 ? void 0 : _a.year;
4380
+ },
4381
+ enumerable: false,
4382
+ configurable: true
4383
+ });
4274
4384
  /**
4275
4385
  * Check if depreciation chart accounts heading related to vehicles category
4276
4386
  */
@@ -4384,6 +4494,14 @@
4384
4494
  classTransformer.Type(function () { return BankTransaction; })
4385
4495
  ], Depreciation.prototype, "bankTransaction", void 0);
4386
4496
 
4497
+ var SoleBusinessActivity$1 = /** @class */ (function (_super) {
4498
+ __extends(SoleBusinessActivity, _super);
4499
+ function SoleBusinessActivity() {
4500
+ return _super !== null && _super.apply(this, arguments) || this;
4501
+ }
4502
+ return SoleBusinessActivity;
4503
+ }(AbstractModel));
4504
+
4387
4505
  var SoleBusiness = /** @class */ (function (_super) {
4388
4506
  __extends(SoleBusiness, _super);
4389
4507
  function SoleBusiness() {
@@ -4397,6 +4515,10 @@
4397
4515
  };
4398
4516
  return SoleBusiness;
4399
4517
  }(SoleBusiness$1));
4518
+ /**
4519
+ * Maximum number of businesses that a person can have, according to the ATO
4520
+ */
4521
+ SoleBusiness.businessesLimit = 6;
4400
4522
  __decorate([
4401
4523
  classTransformer.Type(function () { return User; })
4402
4524
  ], SoleBusiness.prototype, "user", void 0);
@@ -4421,6 +4543,42 @@
4421
4543
  __decorate([
4422
4544
  classTransformer.Type(function () { return Depreciation; })
4423
4545
  ], SoleBusiness.prototype, "depreciations", void 0);
4546
+ __decorate([
4547
+ classTransformer.Type(function () { return SoleBusinessActivity$1; })
4548
+ ], SoleBusiness.prototype, "activity", void 0);
4549
+
4550
+ var SoleBusinessActivity = /** @class */ (function (_super) {
4551
+ __extends(SoleBusinessActivity, _super);
4552
+ function SoleBusinessActivity() {
4553
+ return _super !== null && _super.apply(this, arguments) || this;
4554
+ }
4555
+ return SoleBusinessActivity;
4556
+ }(SoleBusinessActivity$1));
4557
+
4558
+ var SoleDepreciationMethod$1 = /** @class */ (function (_super) {
4559
+ __extends(SoleDepreciationMethod, _super);
4560
+ function SoleDepreciationMethod() {
4561
+ return _super !== null && _super.apply(this, arguments) || this;
4562
+ }
4563
+ return SoleDepreciationMethod;
4564
+ }(AbstractModel));
4565
+
4566
+ exports.SoleDepreciationMethodEnum = void 0;
4567
+ (function (SoleDepreciationMethodEnum) {
4568
+ SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["SBP"] = 1] = "SBP";
4569
+ SoleDepreciationMethodEnum[SoleDepreciationMethodEnum["DEPRECIATION"] = 2] = "DEPRECIATION";
4570
+ })(exports.SoleDepreciationMethodEnum || (exports.SoleDepreciationMethodEnum = {}));
4571
+
4572
+ var SoleDepreciationMethod = /** @class */ (function (_super) {
4573
+ __extends(SoleDepreciationMethod, _super);
4574
+ function SoleDepreciationMethod() {
4575
+ return _super !== null && _super.apply(this, arguments) || this;
4576
+ }
4577
+ SoleDepreciationMethod.prototype.isSBP = function () {
4578
+ return this.method === exports.SoleDepreciationMethodEnum.SBP;
4579
+ };
4580
+ return SoleDepreciationMethod;
4581
+ }(SoleDepreciationMethod$1));
4424
4582
 
4425
4583
  var SoleDetails$1 = /** @class */ (function (_super) {
4426
4584
  __extends(SoleDetails, _super);
@@ -5985,96 +6143,6 @@
5985
6143
  }]
5986
6144
  }] });
5987
6145
 
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
6146
  var VehicleClaimCollection = /** @class */ (function (_super) {
6079
6147
  __extends(VehicleClaimCollection, _super);
6080
6148
  function VehicleClaimCollection() {
@@ -6823,19 +6891,22 @@
6823
6891
  return this.filter(function (depreciation) { return depreciation.isAsset(); });
6824
6892
  };
6825
6893
  DepreciationCollection.prototype.getPlantEquipment = function () {
6826
- return this.filter(function (depreciation) { return depreciation.isPlantEquipment(); });
6894
+ return this.filter(function (depreciation) { return depreciation.isPlantEquipmentPool(); });
6827
6895
  };
6828
6896
  DepreciationCollection.prototype.getCapitalDepreciations = function () {
6829
6897
  return this.filter(function (depreciation) { return depreciation.isCapital(); });
6830
6898
  };
6831
6899
  DepreciationCollection.prototype.getBorrowingExpenseDepreciations = function () {
6832
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isBorrowingExpense(); }));
6900
+ return this.filter(function (depreciation) { return depreciation.isBorrowingExpense(); });
6833
6901
  };
6834
6902
  DepreciationCollection.prototype.getWrittenOffDepreciations = function () {
6835
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isWrittenOff(); }));
6903
+ return this.filter(function (depreciation) { return depreciation.isWrittenOff(); });
6904
+ };
6905
+ DepreciationCollection.prototype.getLVPDepreciations = function () {
6906
+ return this.filter(function (depreciation) { return depreciation.isLVP(); });
6836
6907
  };
6837
- DepreciationCollection.prototype.getLowValuePoolDepreciations = function () {
6838
- return new DepreciationCollection(this.items.filter(function (depreciation) { return depreciation.isLowValuePool(); }));
6908
+ DepreciationCollection.prototype.getSBPDepreciations = function () {
6909
+ return this.filter(function (depreciation) { return depreciation.isSBP(); });
6839
6910
  };
6840
6911
  DepreciationCollection.prototype.getCapitalProjects = function () {
6841
6912
  return uniqBy__default["default"](compact__default["default"](this.items.map(function (depreciation) {
@@ -6846,9 +6917,7 @@
6846
6917
  * Get a new collection of depreciations related to vehicles
6847
6918
  */
6848
6919
  DepreciationCollection.prototype.getVehicleDepreciations = function () {
6849
- return this.create(this.items.filter(function (depreciation) {
6850
- return depreciation.isVehicleDepreciation();
6851
- }));
6920
+ return this.filter(function (depreciation) { return depreciation.isVehicleDepreciation(); });
6852
6921
  };
6853
6922
  DepreciationCollection.prototype.getByTankType = function (tankType) {
6854
6923
  return this.create(this.items.filter(function (depreciation) {
@@ -7265,7 +7334,7 @@
7265
7334
  Object.defineProperty(DepreciationReportItem.prototype, "categoryTitle", {
7266
7335
  get: function () {
7267
7336
  switch (true) {
7268
- case this.isPlantEquipment():
7337
+ case this.isPlantEquipmentPool():
7269
7338
  return 'Plant & Equipment';
7270
7339
  case this.isWrittenOff():
7271
7340
  return 'Written Off Items';
@@ -9118,6 +9187,7 @@
9118
9187
  DepreciationGroupEnum[DepreciationGroupEnum["LOW_VALUE_POOL"] = 2] = "LOW_VALUE_POOL";
9119
9188
  DepreciationGroupEnum[DepreciationGroupEnum["WRITTEN_OFF_ITEMS"] = 3] = "WRITTEN_OFF_ITEMS";
9120
9189
  DepreciationGroupEnum[DepreciationGroupEnum["BORROWING_EXPENSES"] = 4] = "BORROWING_EXPENSES";
9190
+ DepreciationGroupEnum[DepreciationGroupEnum["SMALL_BUSINESS_POOL"] = 5] = "SMALL_BUSINESS_POOL";
9121
9191
  })(exports.DepreciationGroupEnum || (exports.DepreciationGroupEnum = {}));
9122
9192
 
9123
9193
  /**
@@ -9181,6 +9251,11 @@
9181
9251
  description: 'Items below $300, replaced or obsolete are fully deductible',
9182
9252
  icon: 'cart'
9183
9253
  },
9254
+ _a$1[exports.DepreciationGroupEnum.SMALL_BUSINESS_POOL] = {
9255
+ label: 'Small business pool',
9256
+ description: 'The small business pool allows business owners to claim depreciation on plant and equipment items at an accelerated rate.',
9257
+ icon: 'portfolio'
9258
+ },
9184
9259
  _a$1);
9185
9260
 
9186
9261
  var DepreciationReceipt$1 = /** @class */ (function (_super) {
@@ -10067,7 +10142,7 @@
10067
10142
  exports.DeductionSelfEducationTypeEnum.IMPROVE_SKILLS_FOR_CURRENT_EARNINGS_K : null;
10068
10143
  this.workRelatedSelfEducationTotalAmount = this.workRelatedSelfEducationExpenses.sumBy('claimAmount');
10069
10144
  this.lowValuePoolDeductionTotalAmount = this.depreciations.getByTankType(exports.TankTypeEnum.WORK)
10070
- .getLowValuePoolDepreciations().sumBy('claimAmount');
10145
+ .getLVPDepreciations().sumBy('claimAmount');
10071
10146
  this.interestExpensesTotalAmount = this.transactions
10072
10147
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.interestExpenses)
10073
10148
  .sumBy('claimAmount');
@@ -10945,6 +11020,26 @@
10945
11020
  }]
10946
11021
  }] });
10947
11022
 
11023
+ var SoleBusinessActivityService = /** @class */ (function (_super) {
11024
+ __extends(SoleBusinessActivityService, _super);
11025
+ function SoleBusinessActivityService() {
11026
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
11027
+ _this.modelClass = SoleBusinessActivity;
11028
+ _this.url = 'sole-business-activities';
11029
+ _this.isHydra = true;
11030
+ return _this;
11031
+ }
11032
+ return SoleBusinessActivityService;
11033
+ }(RestService));
11034
+ SoleBusinessActivityService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessActivityService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
11035
+ SoleBusinessActivityService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessActivityService, providedIn: 'root' });
11036
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleBusinessActivityService, decorators: [{
11037
+ type: i0.Injectable,
11038
+ args: [{
11039
+ providedIn: 'root'
11040
+ }]
11041
+ }] });
11042
+
10948
11043
  var SoleContactService = /** @class */ (function (_super) {
10949
11044
  __extends(SoleContactService, _super);
10950
11045
  function SoleContactService() {
@@ -10965,6 +11060,61 @@
10965
11060
  }]
10966
11061
  }] });
10967
11062
 
11063
+ /**
11064
+ * @TODO Alex: extend rest service when refactored
11065
+ */
11066
+ var SoleDepreciationMethodService = /** @class */ (function () {
11067
+ function SoleDepreciationMethodService(http, environment, eventDispatcherService, toastService) {
11068
+ this.http = http;
11069
+ this.environment = environment;
11070
+ this.eventDispatcherService = eventDispatcherService;
11071
+ this.toastService = toastService;
11072
+ this.cacheSubject = new rxjs.ReplaySubject(1);
11073
+ this.url = 'sole-depreciation-methods';
11074
+ }
11075
+ SoleDepreciationMethodService.prototype.get = function () {
11076
+ var _this = this;
11077
+ if (!this.cache) {
11078
+ this.http.get(this.environment.apiV2 + "/" + this.url)
11079
+ .pipe(operators.map(function (response) { return classTransformer.plainToClass(SoleDepreciationMethod, response['hydra:member'][0]); }))
11080
+ .subscribe(function (soleDepreciationMethod) {
11081
+ _this.cache = soleDepreciationMethod;
11082
+ _this.cacheSubject.next(_this.cache);
11083
+ return soleDepreciationMethod;
11084
+ });
11085
+ }
11086
+ return this.cacheSubject.asObservable();
11087
+ };
11088
+ SoleDepreciationMethodService.prototype.update = function (soleDepreciationMethod) {
11089
+ var _this = this;
11090
+ return this.http.put(this.environment.apiV2 + "/" + this.url + "/" + soleDepreciationMethod.id, soleDepreciationMethod)
11091
+ .pipe(operators.map(function (soleDepreciationMethodBase) {
11092
+ var method = classTransformer.plainToClass(SoleDepreciationMethod, soleDepreciationMethodBase);
11093
+ _this.cache = method;
11094
+ _this.cacheSubject.next(_this.cache);
11095
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SOLE_DEPRECIATION_METHOD_UPDATED, method));
11096
+ return _this.cache;
11097
+ }), operators.catchError(function (error) {
11098
+ _this.toastService.error(error.error['hydra:description']);
11099
+ return throwError.throwError(error);
11100
+ }));
11101
+ };
11102
+ return SoleDepreciationMethodService;
11103
+ }());
11104
+ SoleDepreciationMethodService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDepreciationMethodService, deps: [{ token: i1__namespace.HttpClient }, { token: 'environment' }, { token: EventDispatcherService }, { token: ToastService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11105
+ SoleDepreciationMethodService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDepreciationMethodService, providedIn: 'root' });
11106
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SoleDepreciationMethodService, decorators: [{
11107
+ type: i0.Injectable,
11108
+ args: [{
11109
+ providedIn: 'root'
11110
+ }]
11111
+ }], ctorParameters: function () {
11112
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
11113
+ type: i0.Inject,
11114
+ args: ['environment']
11115
+ }] }, { type: EventDispatcherService }, { type: ToastService }];
11116
+ } });
11117
+
10968
11118
  /**
10969
11119
  * @TODO TT-1777 Alex: extend from rest service when it refactored
10970
11120
  */
@@ -11638,6 +11788,14 @@
11638
11788
  return updatedProperty;
11639
11789
  }));
11640
11790
  };
11791
+ PropertyService.prototype.updateDepreciationCalculation = function (property) {
11792
+ var _this = this;
11793
+ var propertyToUpdate = classTransformer.plainToClass(Property, { id: property.id, depreciationCalculation: property.depreciationCalculation });
11794
+ return this.update(propertyToUpdate).pipe(operators.map(function (updatedProperty) {
11795
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.PROPERTY_DEPRECIATION_CALCULATION_UPDATED, updatedProperty));
11796
+ return updatedProperty;
11797
+ }));
11798
+ };
11641
11799
  PropertyService.prototype.getByCategoryId = function (id) {
11642
11800
  return this.get().pipe(operators.map(function (properties) {
11643
11801
  return properties.filter(function (property) { return property.category.id === id; });
@@ -12007,62 +12165,104 @@
12007
12165
  return list;
12008
12166
  }
12009
12167
 
12010
- var TransactionReceiptService = /** @class */ (function () {
12011
- function TransactionReceiptService(http, eventDispatcherService, environment) {
12168
+ /**
12169
+ * Abstract service class to work with transactions-like receipt files (transactions, depreciations, e.t.c.)
12170
+ * @Todo TT-2191 refactor service when receipts API will be updated
12171
+ */
12172
+ var ReceiptService = /** @class */ (function () {
12173
+ function ReceiptService(http, eventDispatcherService, environment, toastService) {
12012
12174
  this.http = http;
12013
12175
  this.eventDispatcherService = eventDispatcherService;
12014
12176
  this.environment = environment;
12015
- this.url = 'receipts';
12016
- this.listenEvents();
12177
+ this.toastService = toastService;
12017
12178
  }
12179
+ ReceiptService.prototype.listenEvents = function () {
12180
+ this.listenParentWithReceiptUpdated();
12181
+ this.listenParentWithoutReceiptUpdated();
12182
+ };
12018
12183
  /**
12019
- * Transaction instance is necessary to take the ID and the receipt file from it.
12184
+ * Entity is necessary to take the ID and the receipt file from it.
12020
12185
  */
12021
- TransactionReceiptService.prototype.add = function (transaction) {
12186
+ ReceiptService.prototype.add = function (receiptEntity) {
12022
12187
  var _this = this;
12023
12188
  var formData = new FormData();
12024
- formData.append('file', transaction.file);
12025
- this.http.post(this.environment.apiV2 + "/transactions/" + transaction.id + "/" + this.url, formData)
12026
- .subscribe(function (receiptResponse) {
12027
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_RECEIPT_CREATED, classTransformer.plainToClass(TransactionReceipt, receiptResponse)));
12028
- });
12189
+ formData.append('file', receiptEntity.file);
12190
+ return this.http.post(this.environment.apiV2 + "/" + this.entityType + "/" + receiptEntity.id + "/receipts", formData)
12191
+ .pipe(operators.map(function (receipt) {
12192
+ var uploadedReceipt = _this.createModelInstance(receipt);
12193
+ _this.eventDispatcherService.dispatch(new AppEvent(_this.receiptCreatedEvent, uploadedReceipt));
12194
+ return uploadedReceipt;
12195
+ }));
12029
12196
  };
12030
- /**
12031
- * Transaction instance is necessary to take the ID and the receipt ID from it.
12032
- */
12033
- TransactionReceiptService.prototype.delete = function (transaction) {
12197
+ ReceiptService.prototype.delete = function (receiptEntity) {
12034
12198
  var _this = this;
12035
- this.http.delete(this.environment.apiV2 + "/transactions/" + transaction.id + "/" + this.url + "/" + transaction.receipt.id)
12036
- .subscribe(function () {
12037
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED, transaction));
12038
- });
12039
- };
12040
- TransactionReceiptService.prototype.listenEvents = function () {
12041
- this.listenTransactionWithReceiptUpdated();
12042
- this.listenTransactionWithoutReceiptUpdated();
12199
+ return this.http.delete(this.environment.apiV2 + "/" + this.entityType + "/" + receiptEntity.id + "/receipts/" + receiptEntity.receipt.id)
12200
+ .pipe(operators.map(function () {
12201
+ _this.eventDispatcherService.dispatch(new AppEvent(_this.receiptDeletedEvent, receiptEntity));
12202
+ }));
12043
12203
  };
12044
- TransactionReceiptService.prototype.listenTransactionWithReceiptUpdated = function () {
12204
+ /**
12205
+ * Parent entity was updated with attached receipt
12206
+ */
12207
+ ReceiptService.prototype.listenParentWithReceiptUpdated = function () {
12045
12208
  var _this = this;
12046
- this.eventDispatcherService.on([
12047
- exports.AppEventTypeEnum.TRANSACTION_CREATED_WITH_NEW_RECEIPT,
12048
- exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_NEW_RECEIPT
12049
- ]).subscribe(function (transaction) {
12050
- _this.add(transaction);
12209
+ this.eventDispatcherService.on(this.entityUpdatedWithReceiptEvent)
12210
+ .subscribe(function (receiptEntity) {
12211
+ _this.add(receiptEntity).subscribe();
12051
12212
  });
12052
12213
  };
12053
12214
  /**
12054
- * Case when transaction was updated, but receipt was removed
12215
+ * Parent entity was updated, but receipt was removed
12055
12216
  */
12056
- TransactionReceiptService.prototype.listenTransactionWithoutReceiptUpdated = function () {
12217
+ ReceiptService.prototype.listenParentWithoutReceiptUpdated = function () {
12057
12218
  var _this = this;
12058
- this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_DELETED_RECEIPT)
12059
- .subscribe(function (transaction) {
12060
- _this.delete(transaction);
12219
+ this.eventDispatcherService.on(this.entityUpdatedWithDeletedReceiptEvent)
12220
+ .subscribe(function (receiptEntity) {
12221
+ _this.delete(receiptEntity).subscribe();
12061
12222
  });
12062
12223
  };
12063
- return TransactionReceiptService;
12224
+ ReceiptService.prototype.createModelInstance = function (data) {
12225
+ return classTransformer.plainToClass(this.modelClass, data);
12226
+ };
12227
+ return ReceiptService;
12064
12228
  }());
12065
- 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 });
12229
+ 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 });
12230
+ ReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ReceiptService, providedIn: 'root' });
12231
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ReceiptService, decorators: [{
12232
+ type: i0.Injectable,
12233
+ args: [{
12234
+ providedIn: 'root'
12235
+ }]
12236
+ }], ctorParameters: function () {
12237
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12238
+ type: i0.Inject,
12239
+ args: ['environment']
12240
+ }] }, { type: ToastService }];
12241
+ } });
12242
+
12243
+ /**
12244
+ * @Todo TT-2191 refactor service when receipts API will be updated
12245
+ */
12246
+ var TransactionReceiptService = /** @class */ (function (_super) {
12247
+ __extends(TransactionReceiptService, _super);
12248
+ function TransactionReceiptService(http, eventDispatcherService, environment, toastService) {
12249
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
12250
+ _this.http = http;
12251
+ _this.eventDispatcherService = eventDispatcherService;
12252
+ _this.environment = environment;
12253
+ _this.toastService = toastService;
12254
+ _this.modelClass = TransactionReceipt;
12255
+ _this.entityType = exports.AssetEntityTypeEnum.TRANSACTIONS;
12256
+ _this.receiptCreatedEvent = exports.AppEventTypeEnum.TRANSACTION_RECEIPT_CREATED;
12257
+ _this.receiptDeletedEvent = exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED;
12258
+ _this.entityUpdatedWithReceiptEvent = exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT;
12259
+ _this.entityUpdatedWithDeletedReceiptEvent = exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_DELETED_RECEIPT;
12260
+ _this.listenEvents();
12261
+ return _this;
12262
+ }
12263
+ return TransactionReceiptService;
12264
+ }(ReceiptService));
12265
+ 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 });
12066
12266
  TransactionReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, providedIn: 'root' });
12067
12267
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: TransactionReceiptService, decorators: [{
12068
12268
  type: i0.Injectable,
@@ -12073,7 +12273,7 @@
12073
12273
  return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
12074
12274
  type: i0.Inject,
12075
12275
  args: ['environment']
12076
- }] }];
12276
+ }] }, { type: ToastService }];
12077
12277
  } });
12078
12278
 
12079
12279
  /**
@@ -12197,10 +12397,10 @@
12197
12397
  transactions.forEach(function (transaction, index) {
12198
12398
  // @TODO backend: need to upload file in the same backend endpoint with transaction add/update
12199
12399
  // check if passed receipt and upload file
12200
- if (transaction.file && (transaction.file instanceof File)) {
12400
+ if (transaction.file) {
12201
12401
  transaction.id = response[index].id;
12202
12402
  addedTransactions[index].file = transaction.file;
12203
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_CREATED_WITH_NEW_RECEIPT, addedTransactions[index]));
12403
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT, addedTransactions[index]));
12204
12404
  }
12205
12405
  // @TODO Viktor: implement API for saving of nested transactions
12206
12406
  // add child transactions if exist
@@ -12234,9 +12434,9 @@
12234
12434
  var updatedTransaction = classTransformer.plainToClass(Transaction, response);
12235
12435
  // @TODO need to upload file in the same backend endpoint with transaction add/update
12236
12436
  // check if passed new receipt and upload file
12237
- if (transaction.file && (transaction.file instanceof File)) {
12437
+ if (transaction.file) {
12238
12438
  updatedTransaction.file = transaction.file;
12239
- _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_NEW_RECEIPT, updatedTransaction));
12439
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.TRANSACTION_UPDATED_WITH_RECEIPT, updatedTransaction));
12240
12440
  // receipt file was removed from form - we should delete receipt from transaction
12241
12441
  }
12242
12442
  else if (!transaction.file && transaction.receipt) {
@@ -12260,8 +12460,7 @@
12260
12460
  _this.addBatch(childTransactionsToAdd).subscribe();
12261
12461
  }
12262
12462
  }
12263
- replace(_this.cache, updatedTransaction);
12264
- _this.updateCache();
12463
+ _this.replaceInCache(updatedTransaction);
12265
12464
  return updatedTransaction;
12266
12465
  }));
12267
12466
  };
@@ -12380,8 +12579,7 @@
12380
12579
  // we don't need to keep file after save
12381
12580
  transactionToUpdate.file = null;
12382
12581
  transactionToUpdate.receipt = transactionReceipt;
12383
- replace(_this.cache, transactionToUpdate);
12384
- _this.updateCache();
12582
+ _this.replaceInCache(transactionToUpdate);
12385
12583
  });
12386
12584
  };
12387
12585
  TransactionService.prototype.listenReceiptDeleted = function () {
@@ -12389,8 +12587,7 @@
12389
12587
  this.eventDispatcherService.on(exports.AppEventTypeEnum.TRANSACTION_RECEIPT_DELETED).subscribe(function (transaction) {
12390
12588
  var transactionToUpdate = _this.find(transaction.id);
12391
12589
  transactionToUpdate.receipt = null;
12392
- replace(_this.cache, transactionToUpdate);
12393
- _this.updateCache();
12590
+ _this.replaceInCache(transactionToUpdate);
12394
12591
  });
12395
12592
  };
12396
12593
  TransactionService.prototype.listenVehicleClaimChanges = function () {
@@ -12404,6 +12601,10 @@
12404
12601
  _this.resetCache();
12405
12602
  });
12406
12603
  };
12604
+ TransactionService.prototype.replaceInCache = function (transactionToReplace) {
12605
+ replace(this.cache, transactionToReplace);
12606
+ this.updateCache();
12607
+ };
12407
12608
  return TransactionService;
12408
12609
  }(RestService));
12409
12610
  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 });
@@ -13578,70 +13779,50 @@
13578
13779
  } });
13579
13780
 
13580
13781
  /**
13581
- * Service for work with DepreciationCapitalProjects
13782
+ * @Todo TT-2191 refactor service when receipts API will be updated
13582
13783
  */
13583
- var DepreciationCapitalProjectService = /** @class */ (function () {
13584
- function DepreciationCapitalProjectService(http, environment) {
13585
- this.http = http;
13586
- this.environment = environment;
13587
- this.cacheSubject = new rxjs.ReplaySubject(1);
13784
+ var DepreciationReceiptService = /** @class */ (function (_super) {
13785
+ __extends(DepreciationReceiptService, _super);
13786
+ function DepreciationReceiptService(http, eventDispatcherService, environment, toastService) {
13787
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
13788
+ _this.http = http;
13789
+ _this.eventDispatcherService = eventDispatcherService;
13790
+ _this.environment = environment;
13791
+ _this.toastService = toastService;
13792
+ _this.modelClass = DepreciationReceipt;
13793
+ _this.entityType = exports.AssetEntityTypeEnum.DEPRECIATIONS;
13794
+ _this.receiptCreatedEvent = exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_CREATED;
13795
+ _this.receiptDeletedEvent = exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_DELETED;
13796
+ _this.entityUpdatedWithDeletedReceiptEvent = exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT;
13797
+ _this.entityUpdatedWithReceiptEvent = exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT;
13798
+ _this.listenEvents();
13799
+ return _this;
13588
13800
  }
13589
- DepreciationCapitalProjectService.prototype.get = function (propertyId) {
13590
- var _this = this;
13591
- this.cacheSubject.next([]);
13592
- this.http.get(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects")
13593
- .subscribe(function (capitalProjectsBase) {
13594
- _this.cache = capitalProjectsBase.map(function (capitalProjectBase) {
13595
- return classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase);
13596
- });
13597
- _this.cacheSubject.next(_this.cache);
13598
- });
13599
- return this.cacheSubject.asObservable();
13600
- };
13601
- DepreciationCapitalProjectService.prototype.add = function (capitalProject, propertyId) {
13602
- var _this = this;
13603
- return this.http.post(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects", capitalProject)
13604
- .pipe(operators.map(function (capitalProjectBase) {
13605
- _this.cache.push(classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13606
- _this.cacheSubject.next(_this.cache);
13607
- }));
13608
- };
13609
- DepreciationCapitalProjectService.prototype.update = function (capitalProject, propertyId) {
13610
- var _this = this;
13611
- return this.http.put(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id, capitalProject)
13612
- .pipe(operators.map(function (capitalProjectBase) {
13613
- replace(_this.cache, classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
13614
- _this.cacheSubject.next(_this.cache);
13615
- }));
13616
- };
13617
- DepreciationCapitalProjectService.prototype.delete = function (capitalProject, propertyId) {
13618
- var _this = this;
13619
- return this.http.delete(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id)
13620
- .pipe(operators.map(function () {
13621
- _this.cache = _this.cache.filter(function (item) { return capitalProject.id !== item.id; });
13622
- _this.cacheSubject.next(_this.cache);
13623
- }));
13624
- };
13625
- return DepreciationCapitalProjectService;
13626
- }());
13627
- 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 });
13628
- DepreciationCapitalProjectService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, providedIn: 'root' });
13629
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, decorators: [{
13801
+ return DepreciationReceiptService;
13802
+ }(ReceiptService));
13803
+ 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 });
13804
+ DepreciationReceiptService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationReceiptService, providedIn: 'root' });
13805
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationReceiptService, decorators: [{
13630
13806
  type: i0.Injectable,
13631
13807
  args: [{
13632
13808
  providedIn: 'root'
13633
13809
  }]
13634
13810
  }], ctorParameters: function () {
13635
- return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
13811
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13636
13812
  type: i0.Inject,
13637
13813
  args: ['environment']
13638
- }] }];
13814
+ }] }, { type: ToastService }];
13639
13815
  } });
13640
13816
 
13641
13817
  var DepreciationService = /** @class */ (function (_super) {
13642
13818
  __extends(DepreciationService, _super);
13643
- function DepreciationService() {
13644
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
13819
+ function DepreciationService(http, eventDispatcherService, environment, toastService, depreciationReceiptService) {
13820
+ var _this = _super.call(this, http, eventDispatcherService, environment, toastService) || this;
13821
+ _this.http = http;
13822
+ _this.eventDispatcherService = eventDispatcherService;
13823
+ _this.environment = environment;
13824
+ _this.toastService = toastService;
13825
+ _this.depreciationReceiptService = depreciationReceiptService;
13645
13826
  _this.modelClass = Depreciation;
13646
13827
  _this.url = 'depreciations';
13647
13828
  return _this;
@@ -13665,17 +13846,46 @@
13665
13846
  DepreciationService.prototype.addBatch = function (depreciations) {
13666
13847
  var _this = this;
13667
13848
  return _super.prototype.addBatch.call(this, depreciations).pipe(operators.map(function (newDepreciations) {
13849
+ depreciations.forEach(function (depreciation, index) {
13850
+ // @TODO backend: need to upload file in the same backend endpoint with depreciation add/update
13851
+ // check if passed receipt and upload file
13852
+ if (depreciation.file && (depreciation.file instanceof File)) {
13853
+ depreciation.id = newDepreciations[index].id;
13854
+ newDepreciations[index].file = depreciation.file;
13855
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT, newDepreciations[index]));
13856
+ }
13857
+ });
13668
13858
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATIONS_CREATED, newDepreciations));
13669
13859
  return newDepreciations;
13670
13860
  }));
13671
13861
  };
13862
+ DepreciationService.prototype.update = function (depreciation) {
13863
+ var _this = this;
13864
+ return _super.prototype.update.call(this, depreciation).pipe(operators.map(function (updatedDepreciation) {
13865
+ // @TODO need to upload file in the same backend endpoint with depreciation add/update
13866
+ // check if passed new receipt and upload file
13867
+ if (depreciation.file && (depreciation.file instanceof File)) {
13868
+ updatedDepreciation.file = depreciation.file;
13869
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_RECEIPT, updatedDepreciation));
13870
+ // receipt file was removed from form - we should delete receipt from transaction
13871
+ }
13872
+ else if (!depreciation.file && depreciation.receipt) {
13873
+ _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.DEPRECIATION_UPDATED_WITH_DELETED_RECEIPT, updatedDepreciation));
13874
+ }
13875
+ return updatedDepreciation;
13876
+ }));
13877
+ };
13672
13878
  /**
13673
13879
  * Listen to Depreciations events
13674
13880
  */
13675
13881
  DepreciationService.prototype.listenEvents = function () {
13676
13882
  this.listenToUpdatedLoan();
13883
+ this.listenReceiptAdded();
13884
+ this.listenReceiptDeleted();
13677
13885
  this.listenVehicleClaimChanges();
13678
13886
  this.listenToUpdatedBankAccount();
13887
+ this.listenSoleDepreciationMethodChanges();
13888
+ this.listenPropertyDepreciationCalculationChanges();
13679
13889
  };
13680
13890
  DepreciationService.prototype.getOpenBalance = function (depreciation) {
13681
13891
  return this.http.post(this.environment.apiV2 + "/" + this.url + "/opening-balance?financialYear=" + new FinancialYear().year, depreciation)
@@ -13683,22 +13893,22 @@
13683
13893
  return response || 0;
13684
13894
  }));
13685
13895
  };
13686
- /**
13687
- * Upload depreciation receipt
13688
- * @param depreciation for which will be uploaded receipt
13689
- */
13690
- DepreciationService.prototype.uploadReceipt = function (depreciation) {
13896
+ DepreciationService.prototype.listenReceiptAdded = function () {
13691
13897
  var _this = this;
13692
- var formData = new FormData();
13693
- formData.append('file', depreciation.file);
13694
- depreciation.receipt = null;
13695
- this.http.post(this.environment.apiV2 + "/" + this.url + "/" + depreciation.id + "/receipts", formData)
13696
- .subscribe(function (receiptResponse) {
13898
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_CREATED).subscribe(function (receipt) {
13899
+ var depreciationToUpdate = _this.find(receipt.depreciation.id);
13697
13900
  // we don't need to keep file after save
13698
- depreciation.file = null;
13699
- depreciation.receipt = classTransformer.plainToClass(DepreciationReceipt, receiptResponse);
13700
- replace(_this.cache, depreciation);
13701
- _this.cacheSubject.next(_this.cache.slice());
13901
+ depreciationToUpdate.file = null;
13902
+ depreciationToUpdate.receipt = receipt;
13903
+ _this.replaceInCache(depreciationToUpdate);
13904
+ });
13905
+ };
13906
+ DepreciationService.prototype.listenReceiptDeleted = function () {
13907
+ var _this = this;
13908
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.DEPRECIATION_RECEIPT_DELETED).subscribe(function (depreciation) {
13909
+ var depreciationToUpdate = _this.find(depreciation.id);
13910
+ depreciationToUpdate.receipt = null;
13911
+ _this.replaceInCache(depreciationToUpdate);
13702
13912
  });
13703
13913
  };
13704
13914
  /**
@@ -13735,16 +13945,104 @@
13735
13945
  _this.resetCache();
13736
13946
  });
13737
13947
  };
13948
+ DepreciationService.prototype.replaceInCache = function (depreciationToReplace) {
13949
+ replace(this.cache, depreciationToReplace);
13950
+ this.updateCache();
13951
+ };
13952
+ /**
13953
+ * @TODO Alex: create common method resetCacheOn(events: AppEventType[])
13954
+ */
13955
+ DepreciationService.prototype.listenSoleDepreciationMethodChanges = function () {
13956
+ var _this = this;
13957
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.SOLE_DEPRECIATION_METHOD_UPDATED).subscribe(function () {
13958
+ _this.resetCache();
13959
+ });
13960
+ };
13961
+ /**
13962
+ * @TODO Alex: create common method resetCacheOn(events: AppEventType[])
13963
+ */
13964
+ DepreciationService.prototype.listenPropertyDepreciationCalculationChanges = function () {
13965
+ var _this = this;
13966
+ this.eventDispatcherService.on(exports.AppEventTypeEnum.PROPERTY_DEPRECIATION_CALCULATION_UPDATED).subscribe(function () {
13967
+ _this.resetCache();
13968
+ });
13969
+ };
13738
13970
  return DepreciationService;
13739
13971
  }(RestService));
13740
- 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 });
13972
+ 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 });
13741
13973
  DepreciationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, providedIn: 'root' });
13742
13974
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationService, decorators: [{
13743
13975
  type: i0.Injectable,
13744
13976
  args: [{
13745
13977
  providedIn: 'root'
13746
13978
  }]
13747
- }] });
13979
+ }], ctorParameters: function () {
13980
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
13981
+ type: i0.Inject,
13982
+ args: ['environment']
13983
+ }] }, { type: ToastService }, { type: DepreciationReceiptService }];
13984
+ } });
13985
+
13986
+ /**
13987
+ * Service for work with DepreciationCapitalProjects
13988
+ */
13989
+ var DepreciationCapitalProjectService = /** @class */ (function () {
13990
+ function DepreciationCapitalProjectService(http, environment) {
13991
+ this.http = http;
13992
+ this.environment = environment;
13993
+ this.cacheSubject = new rxjs.ReplaySubject(1);
13994
+ }
13995
+ DepreciationCapitalProjectService.prototype.get = function (propertyId) {
13996
+ var _this = this;
13997
+ this.cacheSubject.next([]);
13998
+ this.http.get(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects")
13999
+ .subscribe(function (capitalProjectsBase) {
14000
+ _this.cache = capitalProjectsBase.map(function (capitalProjectBase) {
14001
+ return classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase);
14002
+ });
14003
+ _this.cacheSubject.next(_this.cache);
14004
+ });
14005
+ return this.cacheSubject.asObservable();
14006
+ };
14007
+ DepreciationCapitalProjectService.prototype.add = function (capitalProject, propertyId) {
14008
+ var _this = this;
14009
+ return this.http.post(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects", capitalProject)
14010
+ .pipe(operators.map(function (capitalProjectBase) {
14011
+ _this.cache.push(classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
14012
+ _this.cacheSubject.next(_this.cache);
14013
+ }));
14014
+ };
14015
+ DepreciationCapitalProjectService.prototype.update = function (capitalProject, propertyId) {
14016
+ var _this = this;
14017
+ return this.http.put(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id, capitalProject)
14018
+ .pipe(operators.map(function (capitalProjectBase) {
14019
+ replace(_this.cache, classTransformer.plainToClass(DepreciationCapitalProject, capitalProjectBase));
14020
+ _this.cacheSubject.next(_this.cache);
14021
+ }));
14022
+ };
14023
+ DepreciationCapitalProjectService.prototype.delete = function (capitalProject, propertyId) {
14024
+ var _this = this;
14025
+ return this.http.delete(this.environment.apiV2 + "/properties/" + propertyId + "/depreciation-capital-projects/" + capitalProject.id)
14026
+ .pipe(operators.map(function () {
14027
+ _this.cache = _this.cache.filter(function (item) { return capitalProject.id !== item.id; });
14028
+ _this.cacheSubject.next(_this.cache);
14029
+ }));
14030
+ };
14031
+ return DepreciationCapitalProjectService;
14032
+ }());
14033
+ 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 });
14034
+ DepreciationCapitalProjectService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, providedIn: 'root' });
14035
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: DepreciationCapitalProjectService, decorators: [{
14036
+ type: i0.Injectable,
14037
+ args: [{
14038
+ providedIn: 'root'
14039
+ }]
14040
+ }], ctorParameters: function () {
14041
+ return [{ type: i1__namespace.HttpClient }, { type: undefined, decorators: [{
14042
+ type: i0.Inject,
14043
+ args: ['environment']
14044
+ }] }];
14045
+ } });
13748
14046
 
13749
14047
  /**
13750
14048
  * Service to handle document-folders and depending documents logic
@@ -16474,7 +16772,7 @@
16474
16772
  if (business === void 0) { business = classTransformer.plainToClass(SoleBusiness, {}); }
16475
16773
  return _super.call(this, {
16476
16774
  name: new forms.FormControl(business.name, forms.Validators.required),
16477
- code: new forms.FormControl(business.code, forms.Validators.required),
16775
+ activity: new forms.FormControl(business.activity, forms.Validators.required),
16478
16776
  description: new forms.FormControl(business.description),
16479
16777
  website: new forms.FormControl(business.website)
16480
16778
  }, business) || this;
@@ -16563,6 +16861,16 @@
16563
16861
  return SoleContactForm;
16564
16862
  }(AbstractForm));
16565
16863
 
16864
+ var SoleDepreciationMethodForm = /** @class */ (function (_super) {
16865
+ __extends(SoleDepreciationMethodForm, _super);
16866
+ function SoleDepreciationMethodForm(soleDepreciationMethod) {
16867
+ return _super.call(this, {
16868
+ method: new forms.FormControl(soleDepreciationMethod.method)
16869
+ }, soleDepreciationMethod) || this;
16870
+ }
16871
+ return SoleDepreciationMethodForm;
16872
+ }(AbstractForm));
16873
+
16566
16874
  var SoleDetailsForm = /** @class */ (function (_super) {
16567
16875
  __extends(SoleDetailsForm, _super);
16568
16876
  function SoleDetailsForm(soleDetails) {
@@ -17527,6 +17835,7 @@
17527
17835
  exports.DepreciationLvpReportItem = DepreciationLvpReportItem;
17528
17836
  exports.DepreciationLvpReportItemCollection = DepreciationLvpReportItemCollection;
17529
17837
  exports.DepreciationReceipt = DepreciationReceipt;
17838
+ exports.DepreciationReceiptService = DepreciationReceiptService;
17530
17839
  exports.DepreciationReportItem = DepreciationReportItem;
17531
17840
  exports.DepreciationReportItemCollection = DepreciationReportItemCollection;
17532
17841
  exports.DepreciationService = DepreciationService;
@@ -17668,6 +17977,8 @@
17668
17977
  exports.ServiceSubscriptionCollection = ServiceSubscriptionCollection;
17669
17978
  exports.ServiceSubscriptionItem = ServiceSubscriptionItem;
17670
17979
  exports.SoleBusiness = SoleBusiness;
17980
+ exports.SoleBusinessActivity = SoleBusinessActivity;
17981
+ exports.SoleBusinessActivityService = SoleBusinessActivityService;
17671
17982
  exports.SoleBusinessAllocation = SoleBusinessAllocation;
17672
17983
  exports.SoleBusinessAllocationsForm = SoleBusinessAllocationsForm;
17673
17984
  exports.SoleBusinessForm = SoleBusinessForm;
@@ -17676,6 +17987,9 @@
17676
17987
  exports.SoleContact = SoleContact;
17677
17988
  exports.SoleContactForm = SoleContactForm;
17678
17989
  exports.SoleContactService = SoleContactService;
17990
+ exports.SoleDepreciationMethod = SoleDepreciationMethod;
17991
+ exports.SoleDepreciationMethodForm = SoleDepreciationMethodForm;
17992
+ exports.SoleDepreciationMethodService = SoleDepreciationMethodService;
17679
17993
  exports.SoleDetails = SoleDetails;
17680
17994
  exports.SoleDetailsForm = SoleDetailsForm;
17681
17995
  exports.SoleDetailsService = SoleDetailsService;