taxtank-core 0.28.59 → 0.28.61

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.
@@ -4455,7 +4455,7 @@
4455
4455
  classTransformer.Type(function () { return BankTransaction; })
4456
4456
  ], Depreciation.prototype, "bankTransaction", void 0);
4457
4457
 
4458
- // @TODO refactor with baseModel in constructor
4458
+ // @TODO Alex: refactor: move here allocations methods, netAmount = amount, grossAmount calculation, remove unused methods, etc.
4459
4459
  var Transaction = /** @class */ (function (_super) {
4460
4460
  __extends(Transaction, _super);
4461
4461
  function Transaction() {
@@ -4531,6 +4531,7 @@
4531
4531
  };
4532
4532
  /**
4533
4533
  * Get net amount (clean amount after all deductions)
4534
+ * @TODO Alex: remove, this.amount should be netAmount actually
4534
4535
  */
4535
4536
  Transaction.prototype.getNetAmount = function () {
4536
4537
  // @TODO fix hack while transactions refactoring (use class-transformer)
@@ -4658,20 +4659,31 @@
4658
4659
  * Check if transaction is completely allocated
4659
4660
  */
4660
4661
  Transaction.prototype.isAllocated = function (allocations) {
4661
- return this.getNetAmount() === this.getAllocatedAmount(allocations);
4662
+ return this.grossAmount === this.getAllocatedAmount(allocations);
4662
4663
  };
4663
4664
  /**
4664
4665
  * Get transaction allocated amount
4665
4666
  */
4666
4667
  Transaction.prototype.getAllocatedAmount = function (allocations) {
4667
- return allocations.getByTransactionsIds([this.id]).amount;
4668
+ return allocations.filterBy('transaction.id', this.id).sumBy('amount');
4668
4669
  };
4669
4670
  /**
4670
4671
  * Get transaction unallocated amount
4671
4672
  */
4672
4673
  Transaction.prototype.getUnallocatedAmount = function (allocations) {
4673
- return this.getNetAmount() - this.getAllocatedAmount(allocations);
4674
+ return this.grossAmount - this.getAllocatedAmount(allocations);
4674
4675
  };
4676
+ Object.defineProperty(Transaction.prototype, "grossAmount", {
4677
+ /**
4678
+ * Total transaction amount including taxes and other additional amounts
4679
+ * @TODO Alex: refactor everything related to amounts
4680
+ */
4681
+ get: function () {
4682
+ return this.isIncome() ? this.getGrossIncome() : this.amount;
4683
+ },
4684
+ enumerable: false,
4685
+ configurable: true
4686
+ });
4675
4687
  return Transaction;
4676
4688
  }(Transaction$1));
4677
4689
  __decorate([
@@ -7729,7 +7741,9 @@
7729
7741
  * Difference between allocated amount and total amount
7730
7742
  */
7731
7743
  TransactionCollection.prototype.getUnallocatedAmount = function (allocations) {
7732
- return +(this.amount - allocations.getByTransactionsIds(this.getIds()).amount).toFixed(2);
7744
+ return this.items.reduce(function (sum, transaction) {
7745
+ return sum + transaction.getUnallocatedAmount(allocations.filterBy('transaction.id', transaction.id));
7746
+ }, 0);
7733
7747
  };
7734
7748
  Object.defineProperty(TransactionCollection.prototype, "cashPosition", {
7735
7749
  /**
@@ -15256,6 +15270,19 @@
15256
15270
  ClientInviteService.prototype.listenEvents = function () {
15257
15271
  this.listenNotifications();
15258
15272
  };
15273
+ /**
15274
+ * Get clients from the different endpoints depending on whether the current user is a client or an employee
15275
+ */
15276
+ ClientInviteService.prototype.get = function (fromEmployee) {
15277
+ var _this = this;
15278
+ this.http.get(this.environment.apiV2 + "/" + this.url + "/" + (fromEmployee ? 'all' : ''))
15279
+ .pipe(operators.map(function (clientInvitesBase) { return classTransformer.plainToClass(ClientInvite, clientInvitesBase); }))
15280
+ .subscribe(function (clientInvites) {
15281
+ _this.cache = clientInvites;
15282
+ _this.updateCache();
15283
+ });
15284
+ return this.cacheSubject.asObservable();
15285
+ };
15259
15286
  /**
15260
15287
  * Import employees for firm from CSV file
15261
15288
  * @param file
@@ -17604,7 +17631,7 @@
17604
17631
  } });
17605
17632
 
17606
17633
  /**
17607
- * @TODO move to collection
17634
+ * @TODO Alex: refactor, move methods to collections and models, remove this service
17608
17635
  */
17609
17636
  var TransactionCalculationService = /** @class */ (function () {
17610
17637
  function TransactionCalculationService() {
@@ -17619,16 +17646,15 @@
17619
17646
  * Check if transaction is allocated
17620
17647
  */
17621
17648
  TransactionCalculationService.prototype.isAllocated = function (transaction, allocations) {
17622
- return transaction.getNetAmount() === this.getAllocatedAmount(new TransactionCollection([transaction]), allocations);
17649
+ return transaction.isAllocated(allocations);
17623
17650
  };
17624
17651
  /**
17625
17652
  * Get collection of allocated transactions
17626
17653
  * @TODO Alex: consider to move to collection
17627
17654
  */
17628
17655
  TransactionCalculationService.prototype.getAllocatedTransactions = function (transactions, allocations) {
17629
- var _this = this;
17630
17656
  return new TransactionCollection(transactions.items.filter(function (transaction) {
17631
- return _this.isAllocated(transaction, allocations);
17657
+ return transaction.isAllocated(allocations);
17632
17658
  }));
17633
17659
  };
17634
17660
  /**
@@ -17636,9 +17662,8 @@
17636
17662
  * @TODO Alex: consider to move to collection
17637
17663
  */
17638
17664
  TransactionCalculationService.prototype.getUnallocatedTransactions = function (transactions, allocations) {
17639
- var _this = this;
17640
17665
  return new TransactionCollection(transactions.items.filter(function (transaction) {
17641
- return !_this.isAllocated(transaction, allocations);
17666
+ return !transaction.isAllocated(allocations);
17642
17667
  }));
17643
17668
  };
17644
17669
  TransactionCalculationService.prototype.getUnallocatedInvoices = function (invoices, allocations) {