taxtank-core 2.0.92 → 2.0.94

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.
@@ -1619,6 +1619,9 @@ var SetupItemTypeEnum;
1619
1619
  SetupItemTypeEnum[SetupItemTypeEnum["BANK_ACCOUNTS"] = 6] = "BANK_ACCOUNTS";
1620
1620
  SetupItemTypeEnum[SetupItemTypeEnum["BANK_ACCOUNT"] = 7] = "BANK_ACCOUNT";
1621
1621
  SetupItemTypeEnum[SetupItemTypeEnum["BUSINESS"] = 8] = "BUSINESS";
1622
+ SetupItemTypeEnum[SetupItemTypeEnum["MONEY"] = 9] = "MONEY";
1623
+ SetupItemTypeEnum[SetupItemTypeEnum["MONEY_BUDGET"] = 10] = "MONEY_BUDGET";
1624
+ SetupItemTypeEnum[SetupItemTypeEnum["MONEY_CALENDAR"] = 11] = "MONEY_CALENDAR";
1622
1625
  })(SetupItemTypeEnum || (SetupItemTypeEnum = {}));
1623
1626
 
1624
1627
  var BudgetTypeEnum;
@@ -5701,7 +5704,7 @@ class AccountSetupItem extends SetupItem {
5701
5704
  return this.status === AccountSetupItemStatusEnum.PENDING;
5702
5705
  }
5703
5706
  get isAchieved() {
5704
- return this.status === AccountSetupItemStatusEnum.SKIPPED;
5707
+ return this.status === AccountSetupItemStatusEnum.ACHIEVED;
5705
5708
  }
5706
5709
  get isCompleted() {
5707
5710
  return [AccountSetupItemStatusEnum.ACHIEVED, AccountSetupItemStatusEnum.SKIPPED].includes(this.status);
@@ -6882,6 +6885,12 @@ class Transaction extends Transaction$1 {
6882
6885
  get month() {
6883
6886
  return this.date.getMonth();
6884
6887
  }
6888
+ inBudget(rule) {
6889
+ return rule.chartAccounts.id === this.chartAccounts.id
6890
+ && rule.incomeSource?.id === this.incomeSource?.id
6891
+ && rule.property?.id === this.property?.id
6892
+ && rule.business?.id === this.business?.id;
6893
+ }
6885
6894
  }
6886
6895
  __decorate([
6887
6896
  Type(() => Transaction)
@@ -7480,6 +7489,13 @@ class TransactionCollection extends TransactionBaseCollection {
7480
7489
  getTaxable() {
7481
7490
  return this.filter(transaction => transaction.claimPercent > 0);
7482
7491
  }
7492
+ filterByBudget(rules) {
7493
+ const transactions = new TransactionCollection();
7494
+ rules.items.forEach(rule => {
7495
+ transactions.push(...this.filter(transaction => transaction.inBudget(rule)).items);
7496
+ });
7497
+ return transactions;
7498
+ }
7483
7499
  }
7484
7500
 
7485
7501
  class TransactionAllocationCollection extends Collection {
@@ -8628,11 +8644,10 @@ class TransactionReportItem {
8628
8644
 
8629
8645
  class BudgetReportItem {
8630
8646
  constructor(rules, transactions) {
8631
- this.category = ChartAccountsCategoryEnum[rules.first.chartAccounts.category];
8632
8647
  this.chartAccounts = rules.first.chartAccounts.name;
8633
8648
  this.forecast = rules.sumBy('amount');
8634
- this.net = Math.abs(transactions.sumBy('amount'));
8635
- this.gross = Math.abs(transactions.sumBy('grossAmount'));
8649
+ this.net = transactions.sumBy('amount');
8650
+ this.gross = transactions.sumBy('grossAmount');
8636
8651
  this.variance = this.forecast - this.net;
8637
8652
  this.variancePercent = round(this.net * 100 / this.forecast, 2);
8638
8653
  this.isIncome = rules.first.chartAccounts.isIncome();
@@ -8646,7 +8661,7 @@ class BudgetRuleItem {
8646
8661
  constructor(rule, transactions) {
8647
8662
  this.rule = rule;
8648
8663
  this.chartAccounts = rule.chartAccounts.name;
8649
- this.tankType = TankTypeEnum[rule.chartAccounts.tankType];
8664
+ this.tankType = rule.chartAccounts.tankType;
8650
8665
  this.frequency = DailyFrequencyEnum[rule.frequency] ?? 'Once';
8651
8666
  this.forecast = rule.amount;
8652
8667
  if (rule.business) {
@@ -8658,7 +8673,7 @@ class BudgetRuleItem {
8658
8673
  if (rule.property) {
8659
8674
  transactions = transactions.filterBy('property.id', rule.property.id);
8660
8675
  }
8661
- this.actual = Math.abs(transactions.sumBy('amount'));
8676
+ this.actual = transactions.sumBy('amount');
8662
8677
  this.startDate = rule.startDate;
8663
8678
  this.endDate = rule.endDate;
8664
8679
  }
@@ -8780,6 +8795,12 @@ class BudgetRuleItemCollection extends Collection {
8780
8795
  });
8781
8796
  return collection;
8782
8797
  }
8798
+ get incomes() {
8799
+ return this.filter(item => item.forecast > 0);
8800
+ }
8801
+ get expenses() {
8802
+ return this.filter(item => item.forecast < 0);
8803
+ }
8783
8804
  }
8784
8805
 
8785
8806
  class SoleBusinessLossCollection extends Collection {
@@ -26998,8 +27019,18 @@ class TransactionBaseFilterForm extends FormGroup {
26998
27019
  }
26999
27020
  listenEvents() {
27000
27021
  this.get('tankType').valueChanges.subscribe(tankType => {
27001
- tankType === TankTypeEnum.SOLE ? this.get('business').enable() : this.get('business').disable();
27002
- tankType === TankTypeEnum.PROPERTY ? this.get('properties').enable() : this.get('properties').disable();
27022
+ if (tankType === TankTypeEnum.SOLE) {
27023
+ this.get('business').enable();
27024
+ }
27025
+ else {
27026
+ this.get('business').disable();
27027
+ }
27028
+ if (tankType === TankTypeEnum.PROPERTY) {
27029
+ this.get('properties').enable();
27030
+ }
27031
+ else {
27032
+ this.get('properties').disable();
27033
+ }
27003
27034
  });
27004
27035
  }
27005
27036
  filter(collection) {
@@ -27029,6 +27060,26 @@ class TransactionBaseFilterForm extends FormGroup {
27029
27060
  }
27030
27061
  return collection;
27031
27062
  }
27063
+ filterBudgetRules(rules) {
27064
+ const value = this.value;
27065
+ const [dateFrom, dateTo] = value.dateRange || [];
27066
+ if (value.tankType) {
27067
+ rules = rules.filterBy('chartAccounts.tankType', value.tankType);
27068
+ }
27069
+ if (value.properties?.length) {
27070
+ rules = rules.filterByProperties(value.properties);
27071
+ }
27072
+ if (value.chartAccounts) {
27073
+ rules = rules.getByChartAccountsName(value.chartAccounts);
27074
+ }
27075
+ if (dateFrom) {
27076
+ rules = rules.filter(rule => rule.startDate >= dateFrom);
27077
+ }
27078
+ if (dateTo) {
27079
+ rules = rules.filter(rule => (rule.endDate || rule.startDate) <= dateTo);
27080
+ }
27081
+ return rules;
27082
+ }
27032
27083
  }
27033
27084
 
27034
27085
  class DepreciationForm extends TransactionBaseForm {