taxtank-core 0.30.135 → 0.30.137

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.
@@ -1640,6 +1640,7 @@ class CollectionDictionary {
1640
1640
  return this.items[key] ? this.items[key] : this.createCollection([]);
1641
1641
  }
1642
1642
  /**
1643
+ * @TODO bad name, it just gets items by keys, same as get method by multiple keys
1643
1644
  * Join several collections by ids, return collection of uniq models (skip duplicates)
1644
1645
  */
1645
1646
  merge(keys) {
@@ -4509,6 +4510,7 @@ var SoleInvoiceStatusesEnum;
4509
4510
  SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["DRAFT"] = 1] = "DRAFT";
4510
4511
  SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PENDING"] = 2] = "PENDING";
4511
4512
  SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID"] = 3] = "PAID";
4513
+ SoleInvoiceStatusesEnum[SoleInvoiceStatusesEnum["PAID_CASH"] = 4] = "PAID_CASH";
4512
4514
  })(SoleInvoiceStatusesEnum || (SoleInvoiceStatusesEnum = {}));
4513
4515
 
4514
4516
  var SoleInvoiceTaxTypeEnum;
@@ -4592,6 +4594,9 @@ class SoleInvoice extends SoleInvoice$1 {
4592
4594
  isPaid() {
4593
4595
  return this.status === SoleInvoiceStatusesEnum.PAID;
4594
4596
  }
4597
+ isPaidCash() {
4598
+ return this.status === SoleInvoiceStatusesEnum.PAID_CASH;
4599
+ }
4595
4600
  isOverdue() {
4596
4601
  return this.isPending() && this.dateTo < new Date();
4597
4602
  }
@@ -5992,6 +5997,9 @@ class BorrowingReport extends BorrowingReport$1 {
5992
5997
  * surplus income to cover your debt obligations
5993
5998
  */
5994
5999
  getNetSurplusRatio(profit, repaymentAmount) {
6000
+ if (!(repaymentAmount && this.loanRepaymentAmount && this.otherLiabilities)) {
6001
+ return 0;
6002
+ }
5995
6003
  return (profit + this.netRentIncome + this.netSalary + this.spouseNetSalary - this.livingExpenses)
5996
6004
  / (repaymentAmount + this.loanRepaymentAmount + this.otherLiabilities);
5997
6005
  }
@@ -6251,6 +6259,9 @@ class Transaction extends Transaction$1 {
6251
6259
  getAllocatedAmount(allocations) {
6252
6260
  return allocations.filterBy('transaction.id', this.id).sumBy('amount');
6253
6261
  }
6262
+ /**
6263
+ * @TODO vik TT-3363
6264
+ */
6254
6265
  getAllocatedClaimAmount(allocations) {
6255
6266
  let coef = 1;
6256
6267
  if (this.isSoleTank() && this.isIncome() && this.isGST) {
@@ -20079,13 +20090,16 @@ class TransactionCalculationService {
20079
20090
  });
20080
20091
  }
20081
20092
  /**
20082
- * Get invoices allocated amounts grouped bu invoice id
20093
+ * Get invoices paid amounts grouped by invoice id
20083
20094
  */
20084
- getAllocationsAmountsByInvoiceId(allocations, invoices) {
20095
+ getInvoicePaidAmountById(allocations, invoices) {
20085
20096
  const allocationsByTransactionId = allocations.groupBy('transaction.id');
20086
20097
  const dictionary = new Dictionary([]);
20087
20098
  invoices.toArray().forEach((invoice) => {
20088
- dictionary.add(invoice.id, allocationsByTransactionId.merge(invoice.itemsCollection.mapBy('transaction.id')).amount || 0);
20099
+ // fully paid if user marked invoice as paid with cash
20100
+ const amount = invoice.isPaidCash() ? invoice.grossPrice
20101
+ : allocationsByTransactionId.merge(invoice.itemsCollection.mapBy('transaction.id')).amount || 0;
20102
+ dictionary.add(invoice.id, amount);
20089
20103
  });
20090
20104
  return dictionary;
20091
20105
  }