taxtank-core 0.8.0 → 0.8.4

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.
@@ -1226,9 +1226,6 @@
1226
1226
  if (items === void 0) { items = []; }
1227
1227
  return new this.constructor(items);
1228
1228
  };
1229
- Collection.prototype.getBy = function (field, value) {
1230
- return this.create(this.items.filter(function (item) { return item[field] === value; }));
1231
- };
1232
1229
  Collection.prototype.groupBy = function (path) {
1233
1230
  if (path === void 0) { path = ''; }
1234
1231
  return new CollectionDictionary(this, path);
@@ -1264,6 +1261,12 @@
1264
1261
  Collection.prototype.getIds = function () {
1265
1262
  return this.items.map(function (item) { return item['id']; });
1266
1263
  };
1264
+ Collection.prototype.findBy = function (path, value) {
1265
+ return this.items.find(function (item) { return get__default["default"](item, path) === value; });
1266
+ };
1267
+ Collection.prototype.getBy = function (path, value) {
1268
+ return this.create(this.items.filter(function (item) { return get__default["default"](item, path) === value; }));
1269
+ };
1267
1270
  /**
1268
1271
  * Get single item by id
1269
1272
  */
@@ -1949,8 +1952,8 @@
1949
1952
  });
1950
1953
  DepreciationCollection.prototype.getClaimAmountByYear = function (year) {
1951
1954
  if (year === void 0) { year = +localStorage.getItem('financialYear'); }
1952
- return this.items.reduce(function (sum, depreciation) {
1953
- return sum + depreciation.getClaimAmountByYear(year);
1955
+ return this.amount - this.items.reduce(function (sum, depreciation) {
1956
+ return sum + depreciation.getCloseBalanceByYear(year);
1954
1957
  }, 0);
1955
1958
  };
1956
1959
  DepreciationCollection.prototype.getCloseBalanceByYear = function (year) {
@@ -4753,7 +4756,7 @@
4753
4756
  * net capital gain tax (includes tax exemptions)
4754
4757
  */
4755
4758
  Property.prototype.calculateNetCGT = function (sale) {
4756
- return this.getCGTExemptionRatio(sale) * this.calculateCGT(sale);
4759
+ return this.getCGTExemptionRatio(sale) * sale.cgt;
4757
4760
  };
4758
4761
  /**
4759
4762
  * guess tax exemption based on property details
@@ -4767,7 +4770,7 @@
4767
4770
  case this.category.id === PropertyCategoryListEnum.OWNER_OCCUPIED:
4768
4771
  return exports.TaxExemptionEnum.PPR;
4769
4772
  // exemption for investment properties owned for at least one year
4770
- case this.getOwnershipDuration(sale, 'years') >= 1:
4773
+ case this.isOneYearExemptionApplicable(sale):
4771
4774
  return exports.TaxExemptionEnum.ONE_YEAR_RULE;
4772
4775
  default:
4773
4776
  return null;
@@ -4790,7 +4793,7 @@
4790
4793
  // main residence become investment (exemption for home office percent usage)
4791
4794
  case exports.TaxExemptionEnum.PPR_TO_INVESTMENT:
4792
4795
  // 1 year CGT discount can still apply (on the income producing % if used for 12 months or more)
4793
- var ratio = this.getOwnershipDuration(sale, 'years') >= 1 ? 0.5 : 1;
4796
+ var ratio = this.isOneYearExemptionApplicable(sale) ? 0.5 : 1;
4794
4797
  return metadata.getClaimPercent() / 100 * ratio;
4795
4798
  // full exemption
4796
4799
  case exports.TaxExemptionEnum.PPR:
@@ -4803,6 +4806,9 @@
4803
4806
  return 1;
4804
4807
  }
4805
4808
  };
4809
+ Property.prototype.isOneYearExemptionApplicable = function (sale) {
4810
+ return sale.cgt > 0 && this.getOwnershipDuration(sale, 'years') > 0;
4811
+ };
4806
4812
  /**
4807
4813
  * ownership duration from purchase till sale
4808
4814
  */
@@ -6217,6 +6223,19 @@
6217
6223
  BankTransactionSummaryFieldsEnum["ALLOCATED_AMOUNT"] = "allocatedAmount";
6218
6224
  })(exports.BankTransactionSummaryFieldsEnum || (exports.BankTransactionSummaryFieldsEnum = {}));
6219
6225
 
6226
+ /**
6227
+ * Class describe configuration options for basiq connect control
6228
+ * https://www.npmjs.com/package/@basiq/basiq-connect-control
6229
+ */
6230
+ var BasiqConfig = /** @class */ (function () {
6231
+ function BasiqConfig(options) {
6232
+ // ID of the DOM element to which Basiq Connect Control will be rendered;
6233
+ this.containerId = 'basiq-control';
6234
+ Object.assign(this, options);
6235
+ }
6236
+ return BasiqConfig;
6237
+ }());
6238
+
6220
6239
  /**
6221
6240
  * access token, needed to access basiq connect ui (https://github.com/basiqio/basiq-connect-ui)
6222
6241
  */
@@ -11390,17 +11409,24 @@
11390
11409
  }] });
11391
11410
 
11392
11411
  var SubscriptionService = /** @class */ (function () {
11393
- function SubscriptionService(http, eventDispatcherService, environment) {
11412
+ function SubscriptionService(http, eventDispatcherService, sseService, environment) {
11394
11413
  this.http = http;
11395
11414
  this.eventDispatcherService = eventDispatcherService;
11415
+ this.sseService = sseService;
11396
11416
  this.environment = environment;
11397
11417
  this.serviceSubscriptionSubject = new rxjs.ReplaySubject(1);
11398
11418
  this.serviceSubscriptionsSubject = new rxjs.ReplaySubject(1);
11399
11419
  this.servicePaymentsSubject = new rxjs.ReplaySubject(1);
11420
+ this.subscriptionChangeSubject = new rxjs.BehaviorSubject(null);
11421
+ this.listenEvents();
11400
11422
  }
11401
- SubscriptionService.prototype.getSubscription = function () {
11423
+ SubscriptionService.prototype.listenEvents = function () {
11424
+ this.listenSubscriptions();
11425
+ };
11426
+ SubscriptionService.prototype.getSubscription = function (force) {
11402
11427
  var _this = this;
11403
- if (!this._serviceSubscription) {
11428
+ if (force === void 0) { force = false; }
11429
+ if (!this._serviceSubscription || force) {
11404
11430
  this.http.get(this.environment.apiV2 + "/subscriptions/last")
11405
11431
  .pipe(operators.map(function (response) {
11406
11432
  return classTransformer.plainToClass(ServiceSubscription, response);
@@ -11427,8 +11453,18 @@
11427
11453
  .subscribe(function (prices) {
11428
11454
  _this._serviceSubscriptions = new ServiceSubscriptionCollection([
11429
11455
  classTransformer.plainToClass(ServiceSubscription, { items: [] }),
11430
- classTransformer.plainToClass(ServiceSubscription, { items: [classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.property, quantity: 2 })] }),
11431
- classTransformer.plainToClass(ServiceSubscription, { items: [classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.property, quantity: 3 })] })
11456
+ classTransformer.plainToClass(ServiceSubscription, {
11457
+ items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
11458
+ price: prices.property,
11459
+ quantity: 2
11460
+ })]
11461
+ }),
11462
+ classTransformer.plainToClass(ServiceSubscription, {
11463
+ items: [classTransformer.plainToClass(ServiceSubscriptionItem, {
11464
+ price: prices.property,
11465
+ quantity: 3
11466
+ })]
11467
+ })
11432
11468
  ]);
11433
11469
  _this._serviceSubscriptions.items.forEach(function (subscription) {
11434
11470
  subscription.items.push(classTransformer.plainToClass(ServiceSubscriptionItem, { price: prices.work, quantity: 1 }));
@@ -11498,19 +11534,21 @@
11498
11534
  * Change subscription plan
11499
11535
  */
11500
11536
  SubscriptionService.prototype.changeSubscription = function (items) {
11537
+ return this.http.put(this.environment.apiV2 + "/subscriptions/items", items);
11538
+ };
11539
+ SubscriptionService.prototype.listenSubscriptions = function () {
11501
11540
  var _this = this;
11502
- return this.http.put(this.environment.apiV2 + "/subscriptions/items", items).pipe(operators.map(function () {
11503
- // Set cache value as null and fire request to backend to get updated subscription value
11504
- _this._serviceSubscription = null;
11505
- _this.serviceSubscriptionSubject.next(_this._serviceSubscription);
11506
- // update property list
11541
+ this.sseService.on("serviceSubscriptions")
11542
+ .pipe(operators.map(function (event) { return classTransformer.plainToClass(ServiceSubscription, event); }))
11543
+ .subscribe(function (subscription) {
11544
+ _this.getSubscription(true).subscribe();
11545
+ _this.subscriptionChangeSubject.next(subscription);
11507
11546
  _this.eventDispatcherService.dispatch(new AppEvent(exports.AppEventTypeEnum.SERVICE_SUBSCRIPTION_UPDATED, null));
11508
- _this.getSubscription().subscribe();
11509
- }));
11547
+ });
11510
11548
  };
11511
11549
  return SubscriptionService;
11512
11550
  }());
11513
- SubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11551
+ SubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, deps: [{ token: i1__namespace.HttpClient }, { token: EventDispatcherService }, { token: SseService }, { token: 'environment' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
11514
11552
  SubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, providedIn: 'root' });
11515
11553
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: SubscriptionService, decorators: [{
11516
11554
  type: i0.Injectable,
@@ -11518,7 +11556,7 @@
11518
11556
  providedIn: 'root'
11519
11557
  }]
11520
11558
  }], ctorParameters: function () {
11521
- return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: undefined, decorators: [{
11559
+ return [{ type: i1__namespace.HttpClient }, { type: EventDispatcherService }, { type: SseService }, { type: undefined, decorators: [{
11522
11560
  type: i0.Inject,
11523
11561
  args: ['environment']
11524
11562
  }] }];
@@ -12941,6 +12979,7 @@
12941
12979
  exports.BankTransactionChartData = BankTransactionChartData;
12942
12980
  exports.BankTransactionCollection = BankTransactionCollection;
12943
12981
  exports.BankTransactionService = BankTransactionService;
12982
+ exports.BasiqConfig = BasiqConfig;
12944
12983
  exports.BasiqJob = BasiqJob;
12945
12984
  exports.BasiqService = BasiqService;
12946
12985
  exports.BasiqToken = BasiqToken;