taxtank-core 0.29.15 → 0.29.18

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 (39) hide show
  1. package/bundles/taxtank-core.umd.js +151 -32
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/report/property/property-report-item-depreciation.collection.js +2 -2
  4. package/esm2015/lib/collections/subscription/index.js +4 -1
  5. package/esm2015/lib/collections/subscription/service-price.collection.js +7 -0
  6. package/esm2015/lib/collections/subscription/service-product.collection.js +8 -0
  7. package/esm2015/lib/collections/subscription/service-subscription.collection.js +17 -1
  8. package/esm2015/lib/collections/subscription/subscription-item.collection.js +4 -1
  9. package/esm2015/lib/db/Models/user/client-income-types.js +3 -3
  10. package/esm2015/lib/models/endpoint/endpoints.const.js +3 -1
  11. package/esm2015/lib/models/index.js +2 -1
  12. package/esm2015/lib/models/service-subscription/index.js +6 -0
  13. package/esm2015/lib/models/service-subscription/service-product.js +6 -1
  14. package/esm2015/lib/models/service-subscription/service-subscription.js +12 -2
  15. package/esm2015/lib/services/http/property/property.service.js +1 -2
  16. package/esm2015/lib/services/http/rest/rest.service.js +2 -2
  17. package/esm2015/lib/services/http/subscription/index.js +2 -1
  18. package/esm2015/lib/services/http/subscription/service-price/service-price.service.js +8 -5
  19. package/esm2015/lib/services/http/subscription/service-product/service-product.service.js +24 -0
  20. package/esm2015/lib/services/http/subscription/service-subscription/subscription.service.js +10 -2
  21. package/esm2015/lib/services/http/user/user.service.js +17 -1
  22. package/fesm2015/taxtank-core.js +119 -28
  23. package/fesm2015/taxtank-core.js.map +1 -1
  24. package/lib/collections/subscription/index.d.ts +3 -0
  25. package/lib/collections/subscription/service-price.collection.d.ts +5 -0
  26. package/lib/collections/subscription/service-product.collection.d.ts +5 -0
  27. package/lib/collections/subscription/service-subscription.collection.d.ts +4 -0
  28. package/lib/collections/subscription/subscription-item.collection.d.ts +2 -1
  29. package/lib/db/Models/user/client-income-types.d.ts +2 -2
  30. package/lib/models/index.d.ts +1 -0
  31. package/lib/models/service-subscription/index.d.ts +5 -0
  32. package/lib/models/service-subscription/service-subscription.d.ts +4 -0
  33. package/lib/services/http/rest/rest.service.d.ts +1 -1
  34. package/lib/services/http/subscription/index.d.ts +1 -0
  35. package/lib/services/http/subscription/service-price/service-price.service.d.ts +9 -6
  36. package/lib/services/http/subscription/service-product/service-product.service.d.ts +14 -0
  37. package/lib/services/http/subscription/service-subscription/subscription.service.d.ts +1 -0
  38. package/lib/services/http/user/user.service.d.ts +11 -0
  39. package/package.json +1 -1
@@ -1483,7 +1483,7 @@
1483
1483
  return _super !== null && _super.apply(this, arguments) || this;
1484
1484
  }
1485
1485
  return ClientIncomeTypes;
1486
- }(AbstractModel));
1486
+ }(ObservableModel));
1487
1487
 
1488
1488
  var EmployeeDetails$1 = /** @class */ (function (_super) {
1489
1489
  __extends(EmployeeDetails, _super);
@@ -2418,6 +2418,11 @@
2418
2418
  };
2419
2419
  return ServiceProduct;
2420
2420
  }(ServiceProduct$1));
2421
+ // const TestEnum = {
2422
+ // 4: 4,
2423
+ // 5: 7,
2424
+ // 6: 6
2425
+ // }
2421
2426
 
2422
2427
  var ServicePrice = /** @class */ (function (_super) {
2423
2428
  __extends(ServicePrice, _super);
@@ -2476,6 +2481,13 @@
2476
2481
  enumerable: false,
2477
2482
  configurable: true
2478
2483
  });
2484
+ Object.defineProperty(ServiceSubscription.prototype, "isPaid", {
2485
+ get: function () {
2486
+ return !!this.stripeId;
2487
+ },
2488
+ enumerable: false,
2489
+ configurable: true
2490
+ });
2479
2491
  Object.defineProperty(ServiceSubscription.prototype, "price", {
2480
2492
  get: function () {
2481
2493
  return this.items.reduce(function (sum, item) { return sum + item.total; }, 0);
@@ -2488,7 +2500,8 @@
2488
2500
  * get title of subscription
2489
2501
  */
2490
2502
  get: function () {
2491
- return this.isTrial ? 'Trial period' : this.items.map(function (item) { return item.price.product.title; }).join(' + ');
2503
+ return this.items.map(function (item) { return item.price.product.title; }).join(' + ');
2504
+ // return this.isTrial ? 'Trial period' : this.items.map((item) => item.price.product.title).join(' + ');
2492
2505
  },
2493
2506
  enumerable: false,
2494
2507
  configurable: true
@@ -2541,6 +2554,13 @@
2541
2554
  enumerable: false,
2542
2555
  configurable: true
2543
2556
  });
2557
+ Object.defineProperty(ServiceSubscription.prototype, "propertyTankItem", {
2558
+ get: function () {
2559
+ return this.items.find(function (item) { return item.price.product.isProperties(); });
2560
+ },
2561
+ enumerable: false,
2562
+ configurable: true
2563
+ });
2544
2564
  ServiceSubscription.prototype.hasPropertyTank = function () {
2545
2565
  return !!this.items.find(function (subscriptionItem) {
2546
2566
  return subscriptionItem.price.product.role.includes(exports.UserRolesEnum.PROPERTY_TANK);
@@ -2571,6 +2591,9 @@
2571
2591
  ServiceSubscription.prototype.hasItem = function (itemToCheck) {
2572
2592
  return !!this.items.find(function (item) { return item.price.id === itemToCheck.price.id; });
2573
2593
  };
2594
+ ServiceSubscription.prototype.hasProduct = function (product) {
2595
+ return !!this.items.find(function (item) { return item.price.product.id === product.id; });
2596
+ };
2574
2597
  /**
2575
2598
  * Recommended number of properties to buy,
2576
2599
  * based on the property service product and the number of properties the user has
@@ -5162,7 +5185,7 @@
5162
5185
  var _this = this;
5163
5186
  this.items = [];
5164
5187
  properties.items.forEach(function (property) {
5165
- var depreciationsByType = new CollectionDictionary(depreciations, 'type');
5188
+ var depreciationsByType = new CollectionDictionary(depreciations.filterBy('property.id', property.id), 'type');
5166
5189
  depreciationsByType.keys.map(function (type) {
5167
5190
  _this.items.push(new PropertyReportItemDepreciation(depreciationsByType.get(type), property, chartAccounts.findBy('id', depreciationsByType.get(type).first.chartAccounts.id)));
5168
5191
  });
@@ -5365,6 +5388,28 @@
5365
5388
  return SoleInvoiceCollection;
5366
5389
  }(Collection));
5367
5390
 
5391
+ var ServicePriceCollection = /** @class */ (function (_super) {
5392
+ __extends(ServicePriceCollection, _super);
5393
+ function ServicePriceCollection() {
5394
+ return _super !== null && _super.apply(this, arguments) || this;
5395
+ }
5396
+ ServicePriceCollection.prototype.getActive = function () {
5397
+ return this.filterBy('isActive', true);
5398
+ };
5399
+ return ServicePriceCollection;
5400
+ }(Collection));
5401
+
5402
+ var ServiceProductCollection = /** @class */ (function (_super) {
5403
+ __extends(ServiceProductCollection, _super);
5404
+ function ServiceProductCollection() {
5405
+ return _super !== null && _super.apply(this, arguments) || this;
5406
+ }
5407
+ ServiceProductCollection.prototype.getActive = function () {
5408
+ return this.filterBy('status', exports.ServiceProductStatusEnum.ACTIVE);
5409
+ };
5410
+ return ServiceProductCollection;
5411
+ }(Collection));
5412
+
5368
5413
  var SubscriptionItemCollection = /** @class */ (function (_super) {
5369
5414
  __extends(SubscriptionItemCollection, _super);
5370
5415
  function SubscriptionItemCollection() {
@@ -5384,6 +5429,9 @@
5384
5429
  enumerable: false,
5385
5430
  configurable: true
5386
5431
  });
5432
+ SubscriptionItemCollection.prototype.hasProduct = function (product) {
5433
+ return !!this.findBy('price.product.id', product.id);
5434
+ };
5387
5435
  return SubscriptionItemCollection;
5388
5436
  }(Collection));
5389
5437
 
@@ -5413,6 +5461,22 @@
5413
5461
  ServiceSubscriptionCollection.prototype.getItems = function () {
5414
5462
  return new SubscriptionItemCollection(flatten__default["default"](this.mapBy('items')));
5415
5463
  };
5464
+ ServiceSubscriptionCollection.prototype.groupByProduct = function (products) {
5465
+ var _this = this;
5466
+ var dictionary = new Dictionary([]);
5467
+ products.toArray().forEach(function (product) {
5468
+ dictionary.add(product.id, _this.findByProduct(product));
5469
+ });
5470
+ return dictionary;
5471
+ };
5472
+ ServiceSubscriptionCollection.prototype.findByProduct = function (product) {
5473
+ return this.find(function (subscription) {
5474
+ return !!subscription.items.find(function (item) { return item.price.product.id === product.id; });
5475
+ });
5476
+ };
5477
+ ServiceSubscriptionCollection.prototype.hasPropertyTank = function () {
5478
+ return !!this.getItems().propertiesItem;
5479
+ };
5416
5480
  return ServiceSubscriptionCollection;
5417
5481
  }(Collection));
5418
5482
 
@@ -8898,6 +8962,29 @@
8898
8962
  })
8899
8963
  ], Notification.prototype, "redirectionLink", void 0);
8900
8964
 
8965
+ var ServicePayment = /** @class */ (function (_super) {
8966
+ __extends(ServicePayment, _super);
8967
+ function ServicePayment() {
8968
+ return _super !== null && _super.apply(this, arguments) || this;
8969
+ }
8970
+ /**
8971
+ * Stripe stores actual links to payment invoices for 30 days.
8972
+ * Link expires after 30 days
8973
+ */
8974
+ ServicePayment.prototype.isInvoiceLinkExpired = function () {
8975
+ var expirationDate = new Date(this.date.setDate(this.date.getDate() + ServicePayment.daysToInvoiceUrlExpired));
8976
+ return expirationDate.getTime() < new Date().getTime();
8977
+ };
8978
+ return ServicePayment;
8979
+ }(ServicePayment$1));
8980
+ ServicePayment.daysToInvoiceUrlExpired = 30;
8981
+ __decorate([
8982
+ classTransformer.Type(function () { return ServiceSubscription; })
8983
+ ], ServicePayment.prototype, "subscription", void 0);
8984
+ __decorate([
8985
+ classTransformer.Type(function () { return Date; })
8986
+ ], ServicePayment.prototype, "date", void 0);
8987
+
8901
8988
  /**
8902
8989
  * Enum with document types which used to API url prefix
8903
8990
  */
@@ -9945,7 +10032,9 @@
9945
10032
  SALARY_FORECAST_POST: new Endpoint('POST', '\\/salary-forecasts'),
9946
10033
  SALARY_FORECAST_PUT: new Endpoint('PUT', '\\/salary-forecasts'),
9947
10034
  SERVICE_PRICES_GET: new Endpoint('GET', '\\/service-prices'),
10035
+ SERVICE_PRODUCTS_GET: new Endpoint('GET', '\\/service-products'),
9948
10036
  SERVICE_PAYMENTS_GET: new Endpoint('GET', '\\/service-payments'),
10037
+ SERVICE_SUBSCRIPTIONS_GET: new Endpoint('GET', '\\/service-subscriptions'),
9949
10038
  SERVICE_PAYMENT_INVOICE_URL_GET: new Endpoint('GET', '\\/service-payments\\/\\d+\\/invoice-url'),
9950
10039
  STRIPE_BILLING_PORTAL_GET: new Endpoint('GET', '\\/stripe\\/billing-portal-session'),
9951
10040
  STRIPE_CHECKOUT_SESSION_POST: new Endpoint('POST', '\\/stripe\\/checkout-session'),
@@ -10345,7 +10434,7 @@
10345
10434
  /**
10346
10435
  * Subscribe to http events and run callback.
10347
10436
  * CSE - Cleint Sent Events
10348
- * @param type The class whose changes should be listened for
10437
+ * @param modelClass
10349
10438
  * @param methods The list of http methods should be listened for
10350
10439
  * @param callback The function to be called when event triggered
10351
10440
  */
@@ -10965,6 +11054,23 @@
10965
11054
  _this.resetCache();
10966
11055
  });
10967
11056
  };
11057
+ /**
11058
+ * @TODO remove when the class refactored on RestService
11059
+ * Subscribe to http events and run callback.
11060
+ * CSE - Cleint Sent Events
11061
+ * @param modelClass
11062
+ * @param methods The list of http methods should be listened for
11063
+ * @param callback The function to be called when event triggered
11064
+ */
11065
+ UserService.prototype.listenCSE = function (modelClass, methods, callback) {
11066
+ var _this = this;
11067
+ callback = callback.bind(this);
11068
+ methods.forEach(function (method) {
11069
+ _this.eventDispatcherService.on2(modelClass.getEventName(method)).subscribe(function (data) {
11070
+ callback(data);
11071
+ });
11072
+ });
11073
+ };
10968
11074
  return UserService;
10969
11075
  }());
10970
11076
  UserService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: UserService, deps: [{ token: i1__namespace.HttpClient }, { token: JwtService }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -12623,29 +12729,6 @@
12623
12729
  myAccount: '/client/my-account/subscription'
12624
12730
  };
12625
12731
 
12626
- var ServicePayment = /** @class */ (function (_super) {
12627
- __extends(ServicePayment, _super);
12628
- function ServicePayment() {
12629
- return _super !== null && _super.apply(this, arguments) || this;
12630
- }
12631
- /**
12632
- * Stripe stores actual links to payment invoices for 30 days.
12633
- * Link expires after 30 days
12634
- */
12635
- ServicePayment.prototype.isInvoiceLinkExpired = function () {
12636
- var expirationDate = new Date(this.date.setDate(this.date.getDate() + ServicePayment.daysToInvoiceUrlExpired));
12637
- return expirationDate.getTime() < new Date().getTime();
12638
- };
12639
- return ServicePayment;
12640
- }(ServicePayment$1));
12641
- ServicePayment.daysToInvoiceUrlExpired = 30;
12642
- __decorate([
12643
- classTransformer.Type(function () { return ServiceSubscription; })
12644
- ], ServicePayment.prototype, "subscription", void 0);
12645
- __decorate([
12646
- classTransformer.Type(function () { return Date; })
12647
- ], ServicePayment.prototype, "date", void 0);
12648
-
12649
12732
  var TaxReview = /** @class */ (function (_super) {
12650
12733
  __extends(TaxReview, _super);
12651
12734
  function TaxReview() {
@@ -15460,7 +15543,6 @@
15460
15543
  }));
15461
15544
  };
15462
15545
  PropertyService.prototype.listenEvents = function () {
15463
- this.cache;
15464
15546
  this.listenShareInviteAccepted();
15465
15547
  // @TODO Alex: consider to refactor property movements logic similar to client-movements
15466
15548
  this.listenMovementsChanges();
@@ -15996,13 +16078,15 @@
15996
16078
  __extends(ServicePriceService, _super);
15997
16079
  function ServicePriceService() {
15998
16080
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
16081
+ _this.endpointUri = 'service-prices';
15999
16082
  _this.modelClass = ServicePrice;
16000
- _this.url = 'service-prices';
16001
- _this.isHydra = true;
16083
+ _this.isApiPlatform = true;
16084
+ _this.collectionClass = ServicePriceCollection;
16085
+ _this.disabledMethods = ['post', 'postBatch', 'put', 'putBatch', 'delete', 'deleteBatch'];
16002
16086
  return _this;
16003
16087
  }
16004
16088
  return ServicePriceService;
16005
- }(RestService));
16089
+ }(RestService$1));
16006
16090
  ServicePriceService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServicePriceService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
16007
16091
  ServicePriceService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServicePriceService, providedIn: 'root' });
16008
16092
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServicePriceService, decorators: [{
@@ -16059,10 +16143,19 @@
16059
16143
  _this.endpointUri = 'service-subscriptions';
16060
16144
  _this.modelClass = ServiceSubscription;
16061
16145
  _this.collectionClass = ServiceSubscriptionCollection;
16062
- _this.disabledMethods = ['post', 'put', 'putBatch', 'delete', 'deleteBatch'];
16146
+ _this.disabledMethods = ['put', 'putBatch', 'delete', 'deleteBatch'];
16063
16147
  _this.listenSubscriptions();
16064
16148
  return _this;
16065
16149
  }
16150
+ SubscriptionService.prototype.startTrial = function (subscription) {
16151
+ var _this = this;
16152
+ return this.http.post(this.apiUrl + "/trial", subscription)
16153
+ .pipe(operators.map(function (response) {
16154
+ var newSubscription = classTransformer.plainToClass(ServiceSubscription, response);
16155
+ _this.handleResponse([newSubscription], 'post');
16156
+ return newSubscription;
16157
+ }));
16158
+ };
16066
16159
  SubscriptionService.prototype.getActive = function () {
16067
16160
  return this.get().pipe(operators.map(function (subscriptions) { return subscriptions.getActive(); }));
16068
16161
  };
@@ -16156,6 +16249,28 @@
16156
16249
  }] }];
16157
16250
  } });
16158
16251
 
16252
+ var ServiceProductService = /** @class */ (function (_super) {
16253
+ __extends(ServiceProductService, _super);
16254
+ function ServiceProductService() {
16255
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
16256
+ _this.collectionClass = ServiceProductCollection;
16257
+ _this.modelClass = ServiceProduct;
16258
+ _this.endpointUri = 'service-products';
16259
+ _this.disabledMethods = ['post', 'postBatch', 'put', 'putBatch', 'delete', 'deleteBatch'];
16260
+ _this.isApiPlatform = true;
16261
+ return _this;
16262
+ }
16263
+ return ServiceProductService;
16264
+ }(RestService$1));
16265
+ ServiceProductService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServiceProductService, deps: null, target: i0__namespace.ɵɵFactoryTarget.Injectable });
16266
+ ServiceProductService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServiceProductService, providedIn: 'root' });
16267
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ServiceProductService, decorators: [{
16268
+ type: i0.Injectable,
16269
+ args: [{
16270
+ providedIn: 'root'
16271
+ }]
16272
+ }] });
16273
+
16159
16274
  /**
16160
16275
  * Service to work with tax review history
16161
16276
  */
@@ -21443,8 +21558,11 @@
21443
21558
  exports.ServicePayment = ServicePayment;
21444
21559
  exports.ServicePaymentService = ServicePaymentService;
21445
21560
  exports.ServicePrice = ServicePrice;
21561
+ exports.ServicePriceCollection = ServicePriceCollection;
21446
21562
  exports.ServicePriceService = ServicePriceService;
21447
21563
  exports.ServiceProduct = ServiceProduct;
21564
+ exports.ServiceProductCollection = ServiceProductCollection;
21565
+ exports.ServiceProductService = ServiceProductService;
21448
21566
  exports.ServiceSubscription = ServiceSubscription;
21449
21567
  exports.ServiceSubscriptionCollection = ServiceSubscriptionCollection;
21450
21568
  exports.ServiceSubscriptionItem = ServiceSubscriptionItem;
@@ -21484,6 +21602,7 @@
21484
21602
  exports.SoleInvoiceTemplateForm = SoleInvoiceTemplateForm;
21485
21603
  exports.SoleInvoiceTemplateService = SoleInvoiceTemplateService;
21486
21604
  exports.SseService = SseService;
21605
+ exports.SubscriptionItemCollection = SubscriptionItemCollection;
21487
21606
  exports.SubscriptionService = SubscriptionService;
21488
21607
  exports.TAX_RETURN_CATEGORIES = TAX_RETURN_CATEGORIES;
21489
21608
  exports.TYPE_LOAN = TYPE_LOAN;