taxtank-core 2.0.97 → 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.calendarEvents.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) {
@@ -8804,12 +8804,15 @@ class BudgetRuleCollection extends Collection {
8804
8804
  const propertyIds = properties.map(property => property.id);
8805
8805
  return this.filter(rule => propertyIds.includes(rule.property?.id));
8806
8806
  }
8807
- get calendarEvents() {
8808
- return new MoneyCalendarEventCollection(this.map(rule => rule.calendarEvents.items).flat());
8807
+ getCalendarEvents(inCalendar = true) {
8808
+ return new MoneyCalendarEventCollection(this.map(rule => rule.getCalendarEvents(inCalendar).items).flat());
8809
8809
  }
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));
@@ -8841,8 +8844,8 @@ class BudgetRuleItemCollection extends Collection {
8841
8844
  get rules() {
8842
8845
  return new BudgetRuleCollection(this.mapBy('rule'));
8843
8846
  }
8844
- get calendarEvents() {
8845
- return new MoneyCalendarEventCollection(this.map(item => item.rule.calendarEvents.toArray()).flat());
8847
+ getCalendarEvents(inCalendar = false) {
8848
+ return new MoneyCalendarEventCollection(this.map(item => item.rule.getCalendarEvents(inCalendar).toArray()).flat());
8846
8849
  }
8847
8850
  onTrack() {
8848
8851
  return this.sumBy('variance') >= 0;
@@ -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.calendarEvents.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
 
@@ -9965,8 +9968,8 @@ class FinancialGoalCollection extends Collection {
9965
9968
  // const loan = '';
9966
9969
  // });
9967
9970
  // }
9968
- get calendarEvents() {
9969
- return new MoneyCalendarEventCollection(this.map(rule => rule.calendarEvents.items).flat());
9971
+ getCalendarEvents(inCalendar = false) {
9972
+ return new MoneyCalendarEventCollection(this.map(rule => rule.getCalendarEvents(inCalendar).items).flat());
9970
9973
  }
9971
9974
  }
9972
9975
 
@@ -11721,8 +11724,8 @@ class BudgetRule extends BudgetRule$1 {
11721
11724
  /**
11722
11725
  * creates recurring calendar events based on frequency
11723
11726
  */
11724
- get calendarEvents() {
11725
- if (!this.inCalendar) {
11727
+ getCalendarEvents(inCalendar = false) {
11728
+ if (inCalendar && !this.inCalendar) {
11726
11729
  return new MoneyCalendarEventCollection([]);
11727
11730
  }
11728
11731
  const paymentDates = this.frequency
@@ -11974,8 +11977,8 @@ class FinancialGoal extends ObservableModel {
11974
11977
  /**
11975
11978
  * creates recurring calendar events based on paymentFrequency
11976
11979
  */
11977
- get calendarEvents() {
11978
- if (!this.inCalendar || this.isPropertyType()) {
11980
+ getCalendarEvents(inCalendar = false) {
11981
+ if (inCalendar && (!this.inCalendar || this.isPropertyType())) {
11979
11982
  return new MoneyCalendarEventCollection([]);
11980
11983
  }
11981
11984
  const paymentDates = recurringDates(this.paymentFrequency, this.startDate, this.endDate);
@@ -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);