taxtank-core 0.29.22 → 0.29.25
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.
- package/bundles/taxtank-core.umd.js +42 -17
- package/bundles/taxtank-core.umd.js.map +1 -1
- package/esm2015/lib/collections/subscription/service-subscription.collection.js +10 -5
- package/esm2015/lib/collections/subscription/subscription-item.collection.js +5 -1
- package/esm2015/lib/db/Models/subscription/service-subscription.js +1 -1
- package/esm2015/lib/models/endpoint/endpoints.const.js +5 -6
- package/esm2015/lib/models/service-subscription/service-price.js +5 -1
- package/esm2015/lib/models/service-subscription/service-subscription.js +7 -1
- package/esm2015/lib/services/http/subscription/service-subscription/subscription.service.js +6 -1
- package/fesm2015/taxtank-core.js +38 -17
- package/fesm2015/taxtank-core.js.map +1 -1
- package/lib/collections/subscription/service-subscription.collection.d.ts +4 -3
- package/lib/collections/subscription/subscription-item.collection.d.ts +2 -0
- package/lib/db/Models/subscription/service-subscription.d.ts +1 -0
- package/lib/models/service-subscription/service-price.d.ts +1 -0
- package/lib/models/service-subscription/service-subscription.d.ts +2 -0
- package/lib/services/http/subscription/service-subscription/subscription.service.d.ts +3 -0
- package/package.json +1 -1
package/fesm2015/taxtank-core.js
CHANGED
|
@@ -1375,10 +1375,22 @@ ServiceProduct.quantity = 3;
|
|
|
1375
1375
|
// 6: 6
|
|
1376
1376
|
// }
|
|
1377
1377
|
|
|
1378
|
+
var ServicePriceTypeEnum;
|
|
1379
|
+
(function (ServicePriceTypeEnum) {
|
|
1380
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["DEPRECATED"] = 0] = "DEPRECATED";
|
|
1381
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["MONTHLY"] = 1] = "MONTHLY";
|
|
1382
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["MONTHLY_PACKAGE"] = 2] = "MONTHLY_PACKAGE";
|
|
1383
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["YEARLY"] = 3] = "YEARLY";
|
|
1384
|
+
ServicePriceTypeEnum[ServicePriceTypeEnum["YEARLY_PACKAGE"] = 4] = "YEARLY_PACKAGE";
|
|
1385
|
+
})(ServicePriceTypeEnum || (ServicePriceTypeEnum = {}));
|
|
1386
|
+
|
|
1378
1387
|
class ServicePrice extends ServicePrice$1 {
|
|
1379
1388
|
toSubscriptionItem() {
|
|
1380
1389
|
return plainToClass(ServiceSubscriptionItem, { price: this, quantity: this.product.minQty });
|
|
1381
1390
|
}
|
|
1391
|
+
isAnnual() {
|
|
1392
|
+
return [ServicePriceTypeEnum.YEARLY, ServicePriceTypeEnum.YEARLY_PACKAGE].includes(this.type);
|
|
1393
|
+
}
|
|
1382
1394
|
}
|
|
1383
1395
|
__decorate([
|
|
1384
1396
|
Type(() => ServiceProduct)
|
|
@@ -3872,15 +3884,6 @@ class SoleInvoiceCollection extends Collection {
|
|
|
3872
3884
|
}
|
|
3873
3885
|
}
|
|
3874
3886
|
|
|
3875
|
-
var ServicePriceTypeEnum;
|
|
3876
|
-
(function (ServicePriceTypeEnum) {
|
|
3877
|
-
ServicePriceTypeEnum[ServicePriceTypeEnum["DEPRECATED"] = 0] = "DEPRECATED";
|
|
3878
|
-
ServicePriceTypeEnum[ServicePriceTypeEnum["MONTHLY"] = 1] = "MONTHLY";
|
|
3879
|
-
ServicePriceTypeEnum[ServicePriceTypeEnum["MONTHLY_PACKAGE"] = 2] = "MONTHLY_PACKAGE";
|
|
3880
|
-
ServicePriceTypeEnum[ServicePriceTypeEnum["YEARLY"] = 3] = "YEARLY";
|
|
3881
|
-
ServicePriceTypeEnum[ServicePriceTypeEnum["YEARLY_PACKAGE"] = 4] = "YEARLY_PACKAGE";
|
|
3882
|
-
})(ServicePriceTypeEnum || (ServicePriceTypeEnum = {}));
|
|
3883
|
-
|
|
3884
3887
|
/**
|
|
3885
3888
|
* @TODO vik refactor
|
|
3886
3889
|
*/
|
|
@@ -3938,6 +3941,9 @@ class SubscriptionItemCollection extends Collection {
|
|
|
3938
3941
|
hasProduct(product) {
|
|
3939
3942
|
return !!this.findBy('price.product.id', product.id);
|
|
3940
3943
|
}
|
|
3944
|
+
getPrices() {
|
|
3945
|
+
return new ServicePriceCollection(this.mapBy('price'));
|
|
3946
|
+
}
|
|
3941
3947
|
}
|
|
3942
3948
|
|
|
3943
3949
|
class ServiceSubscriptionCollection extends Collection {
|
|
@@ -3963,17 +3969,22 @@ class ServiceSubscriptionCollection extends Collection {
|
|
|
3963
3969
|
return new SubscriptionItemCollection(flatten(this.mapBy('items')));
|
|
3964
3970
|
}
|
|
3965
3971
|
groupByProduct(products) {
|
|
3966
|
-
const
|
|
3972
|
+
const collectionDictionary = new CollectionDictionary(new ServiceSubscriptionCollection([]));
|
|
3967
3973
|
products.toArray().forEach((product) => {
|
|
3968
|
-
|
|
3974
|
+
collectionDictionary.add(product.id, this.filterByProduct(product));
|
|
3969
3975
|
});
|
|
3970
|
-
return
|
|
3976
|
+
return collectionDictionary;
|
|
3971
3977
|
}
|
|
3972
3978
|
findByProduct(product) {
|
|
3973
3979
|
return this.find((subscription) => {
|
|
3974
3980
|
return !!subscription.items.find((item) => item.price.product.id === product.id);
|
|
3975
3981
|
});
|
|
3976
3982
|
}
|
|
3983
|
+
filterByProduct(product) {
|
|
3984
|
+
return this.filter((subscription) => {
|
|
3985
|
+
return !!subscription.items.find((item) => item.price.product.id === product.id);
|
|
3986
|
+
});
|
|
3987
|
+
}
|
|
3977
3988
|
hasPropertyTank() {
|
|
3978
3989
|
return !!this.getItems().propertiesItem;
|
|
3979
3990
|
}
|
|
@@ -4861,6 +4872,9 @@ class ServiceSubscription extends ServiceSubscription$1 {
|
|
|
4861
4872
|
// Number of days after which the trial time will be expired
|
|
4862
4873
|
this.lastTrialDays = 4;
|
|
4863
4874
|
}
|
|
4875
|
+
get frequency() {
|
|
4876
|
+
return this.isAnnual() ? 'year' : 'month';
|
|
4877
|
+
}
|
|
4864
4878
|
get isTrial() {
|
|
4865
4879
|
return !this.stripeId;
|
|
4866
4880
|
}
|
|
@@ -4951,6 +4965,9 @@ class ServiceSubscription extends ServiceSubscription$1 {
|
|
|
4951
4965
|
isPackage() {
|
|
4952
4966
|
return this.items.length === ServiceProduct.quantity;
|
|
4953
4967
|
}
|
|
4968
|
+
isAnnual() {
|
|
4969
|
+
return !!(this.getItems().getPrices().annual.length || this.getItems().getPrices().annualPackage.length);
|
|
4970
|
+
}
|
|
4954
4971
|
/**
|
|
4955
4972
|
* Recommended number of properties to buy,
|
|
4956
4973
|
* based on the property service product and the number of properties the user has
|
|
@@ -7732,7 +7749,8 @@ const ENDPOINTS = {
|
|
|
7732
7749
|
PROPERTIES_SALES_GET: new Endpoint('GET', '\\/properties\\/sales'),
|
|
7733
7750
|
PROPERTIES_SUGGESTIONS_GET: new Endpoint('GET', '/property\\/\\w+\\/v2\\/.*$'),
|
|
7734
7751
|
PROPERTIES_VALUATIONS_DOCUMENTS_POST: new Endpoint('POST', '\\/properties\\/\\d+\\/valuations\\/\\d+\\/documents'),
|
|
7735
|
-
|
|
7752
|
+
// @TODO rename
|
|
7753
|
+
PRORATION_COST_POST: new Endpoint('PUT', '\\/service-subscriptions\\/\\d+\\/proration-cost'),
|
|
7736
7754
|
SALARY_FORECAST_GET: new Endpoint('GET', '\\/salary-forecasts'),
|
|
7737
7755
|
SALARY_FORECAST_POST: new Endpoint('POST', '\\/salary-forecasts'),
|
|
7738
7756
|
SALARY_FORECAST_PUT: new Endpoint('PUT', '\\/salary-forecasts'),
|
|
@@ -7740,11 +7758,9 @@ const ENDPOINTS = {
|
|
|
7740
7758
|
SERVICE_PRODUCTS_GET: new Endpoint('GET', '\\/service-products'),
|
|
7741
7759
|
SERVICE_PAYMENTS_GET: new Endpoint('GET', '\\/service-payments'),
|
|
7742
7760
|
SERVICE_SUBSCRIPTIONS_GET: new Endpoint('GET', '\\/service-subscriptions'),
|
|
7761
|
+
SERVICE_SUBSCRIPTIONS_CANCEL: new Endpoint('PUT', '\\/service-subscriptions\\/\\d+\\/cancel'),
|
|
7743
7762
|
SERVICE_PAYMENT_INVOICE_URL_GET: new Endpoint('GET', '\\/service-payments\\/\\d+\\/invoice-url'),
|
|
7744
|
-
|
|
7745
|
-
STRIPE_CHECKOUT_SESSION_POST: new Endpoint('POST', '\\/stripe\\/checkout-session'),
|
|
7746
|
-
SUBSCRIPTION_LAST_GET: new Endpoint('GET', '\\/subscriptions\\/last'),
|
|
7747
|
-
SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/subscriptions\\/items'),
|
|
7763
|
+
SUBSCRIPTION_ITEMS_PUT: new Endpoint('PUT', '\\/service-subscriptions\\/\\d+\\/items'),
|
|
7748
7764
|
SOLE_BUSINESSES_GET: new Endpoint('GET', '\\/sole-businesses'),
|
|
7749
7765
|
SOLE_BUSINESSES_POST: new Endpoint('POST', '\\/sole-businesses'),
|
|
7750
7766
|
SOLE_BUSINESSES_PUT: new Endpoint('PUT', '\\/sole-businesses\\/\\d+'),
|
|
@@ -13376,6 +13392,7 @@ class SubscriptionService extends RestService$1 {
|
|
|
13376
13392
|
return this.getActive().pipe(map((subscriptions) => subscriptions.getTrials()));
|
|
13377
13393
|
}
|
|
13378
13394
|
/**
|
|
13395
|
+
* @TODO remove
|
|
13379
13396
|
* redirect to stripe payment page
|
|
13380
13397
|
*/
|
|
13381
13398
|
checkoutRedirect(subscription) {
|
|
@@ -13393,6 +13410,7 @@ class SubscriptionService extends RestService$1 {
|
|
|
13393
13410
|
});
|
|
13394
13411
|
}
|
|
13395
13412
|
/**
|
|
13413
|
+
* @TODO remove
|
|
13396
13414
|
* redirect to stripe billing page
|
|
13397
13415
|
*/
|
|
13398
13416
|
billingRedirect(returnUrl) {
|
|
@@ -13416,6 +13434,9 @@ class SubscriptionService extends RestService$1 {
|
|
|
13416
13434
|
changeSubscription(subscription) {
|
|
13417
13435
|
return this.http.put(`${this.environment.apiV2}/service-subscriptions/${subscription.id}`, subscription);
|
|
13418
13436
|
}
|
|
13437
|
+
cancel(subscription) {
|
|
13438
|
+
return this.http.put(`${this.environment.apiV2}/service-subscriptions/${subscription.id}/cancel`, {});
|
|
13439
|
+
}
|
|
13419
13440
|
listenSubscriptions() {
|
|
13420
13441
|
this.sseService.on(`serviceSubscriptions`)
|
|
13421
13442
|
.subscribe((serviceSubscription) => {
|