taxtank-core 2.0.98 → 2.0.99

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.
@@ -2355,8 +2355,8 @@ class MoneyCalendarEventCollection extends CalendarEventCollection {
2355
2355
  get incomes() {
2356
2356
  return this.filter(event => event.extendedProps.chartAccounts.isIncome());
2357
2357
  }
2358
- filterByDate(dateFrom = new FinancialYear().startDate, dateTo = new FinancialYear().endDate) {
2359
- return this.filterByRange('date', dateFrom, dateTo);
2358
+ filterByDate(dateFrom, dateTo) {
2359
+ return this.filterByRange('date', dateFrom ?? new FinancialYear().startDate, dateTo ?? new FinancialYear().endDate);
2360
2360
  }
2361
2361
  getByMonth(index) {
2362
2362
  return new MoneyCalendarEventCollection(this.items.filter(event => event.inMonth(index)));
@@ -8668,11 +8668,11 @@ class BudgetRuleItem {
8668
8668
  if (rule.property) {
8669
8669
  transactions = transactions.filterBy('property.id', rule.property.id);
8670
8670
  }
8671
- this.forecast = rule.getCalendarEvents(false).filterByDate(dateFrom, dateTo).amount;
8671
+ this.forecast = rule.getCalendarEvents().filterByDate(dateFrom, dateTo).amount;
8672
8672
  this.transactions = transactions;
8673
8673
  this.actual = transactions.sumBy(isGross ? 'grossAmount' : 'amount');
8674
8674
  this.variance = this.actual - this.forecast;
8675
- this.variancePercent = round(this.actual * 100 / this.forecast, 2);
8675
+ this.variancePercent = round(this.variance * 100 / this.forecast, 2);
8676
8676
  }
8677
8677
  getSource() {
8678
8678
  switch (true) {
@@ -8810,6 +8810,9 @@ class BudgetRuleCollection extends Collection {
8810
8810
  getByMonth(index) {
8811
8811
  return new BudgetRuleCollection(this.items.filter(rule => rule.inMonth(index)));
8812
8812
  }
8813
+ getByDate(dateFrom, dateTo) {
8814
+ return this.filter(rule => !!rule.getCalendarEvents().filterByDate(dateFrom, dateTo).length);
8815
+ }
8813
8816
  getByChartAccountsName(name) {
8814
8817
  const searchQuery = name.toLowerCase().trim();
8815
8818
  return this.filter(rule => rule.chartAccounts.name.toLowerCase().includes(searchQuery));
@@ -8857,13 +8860,13 @@ class BudgetRuleItemCollection extends Collection {
8857
8860
  * @TODO move to property to avoid recalculations?
8858
8861
  */
8859
8862
  getForecastByMonth(month) {
8860
- return this.getCalendarEvents(false).getByMonth(month).amount;
8863
+ return this.getCalendarEvents().getByMonth(month).amount;
8861
8864
  }
8862
8865
  /**
8863
8866
  * @TODO move to property to avoid recalculations?
8864
8867
  */
8865
8868
  get variancePercent() {
8866
- return round(this.sumBy('actual') * 100 / this.sumBy('forecast'), 2);
8869
+ return round(this.sumBy('variance') * 100 / this.sumBy('forecast'), 2);
8867
8870
  }
8868
8871
  }
8869
8872
 
@@ -11721,7 +11724,7 @@ class BudgetRule extends BudgetRule$1 {
11721
11724
  /**
11722
11725
  * creates recurring calendar events based on frequency
11723
11726
  */
11724
- getCalendarEvents(inCalendar = true) {
11727
+ getCalendarEvents(inCalendar = false) {
11725
11728
  if (inCalendar && !this.inCalendar) {
11726
11729
  return new MoneyCalendarEventCollection([]);
11727
11730
  }
@@ -27112,11 +27115,8 @@ class TransactionBaseFilterForm extends FormGroup {
27112
27115
  if (value.chartAccounts) {
27113
27116
  rules = rules.getByChartAccountsName(value.chartAccounts);
27114
27117
  }
27115
- if (dateFrom) {
27116
- rules = rules.filter(rule => rule.startDate >= dateFrom);
27117
- }
27118
- if (dateTo) {
27119
- rules = rules.filter(rule => (rule.endDate || rule.startDate) <= dateTo);
27118
+ if (dateFrom || dateTo) {
27119
+ rules = rules.getByDate(dateFrom, dateTo);
27120
27120
  }
27121
27121
  if (value.properties?.length) {
27122
27122
  rules = rules.filterByProperties(value.properties);