taxtank-core 2.0.76 → 2.0.78

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Inject, Injectable, inject, EventEmitter, NgModule, InjectionToken, Pipe } from '@angular/core';
3
3
  import * as i1$1 from '@angular/common';
4
- import { formatDate, CommonModule as CommonModule$1, CurrencyPipe, DatePipe } from '@angular/common';
4
+ import { formatDate, CurrencyPipe, CommonModule as CommonModule$1, DatePipe } from '@angular/common';
5
5
  import * as i1 from '@angular/common/http';
6
6
  import { HttpClient, HttpErrorResponse, HttpParams, HTTP_INTERCEPTORS } from '@angular/common/http';
7
7
  import { map, filter, catchError, finalize, switchMap, first as first$1, take, mergeMap, startWith, debounceTime, distinctUntilChanged } from 'rxjs/operators';
@@ -8618,13 +8618,14 @@ class BudgetReportItem {
8618
8618
  this.category = ChartAccountsCategoryEnum[rules.first.chartAccounts.category];
8619
8619
  this.chartAccounts = rules.first.chartAccounts.name;
8620
8620
  this.forecast = rules.sumBy('amount');
8621
- this.actual = Math.abs(transactions.sumBy('amount'));
8622
- this.difference = this.forecast - this.actual;
8623
- this.differencePercent = round(this.actual * 100 / this.forecast, 2);
8621
+ this.net = Math.abs(transactions.sumBy('amount'));
8622
+ this.gross = Math.abs(transactions.sumBy('grossAmount'));
8623
+ this.variance = this.forecast - this.net;
8624
+ this.variancePercent = round(this.net * 100 / this.forecast, 2);
8624
8625
  this.isIncome = rules.first.chartAccounts.isIncome();
8625
8626
  }
8626
8627
  onTrack() {
8627
- return (this.isIncome && this.difference <= 0) || (!this.isIncome && this.difference >= 0);
8628
+ return (this.isIncome && this.variance <= 0) || (!this.isIncome && this.variance >= 0);
8628
8629
  }
8629
8630
  }
8630
8631
 
@@ -11051,6 +11052,15 @@ class AppEvent2 {
11051
11052
  * https://primefaces.github.io/primefaces/jsdocs/classes/node_modules__fullcalendar_common_main.EventApi.html#extendedProps
11052
11053
  */
11053
11054
  class CalendarEvent {
11055
+ constructor() {
11056
+ this.today = moment().startOf('day');
11057
+ }
11058
+ get isOverdue() {
11059
+ return moment(this.date).isBefore(this.today, 'day');
11060
+ }
11061
+ get isUpcoming() {
11062
+ return moment(this.date).isAfter(this.today, 'day');
11063
+ }
11054
11064
  }
11055
11065
 
11056
11066
  /**
@@ -11519,7 +11529,8 @@ var SharesightPortfolioMessages;
11519
11529
  * - Iteratively adds the appropriate duration (week/month) until the end date is reached.
11520
11530
  * - Returns all occurrence dates including the start date and the last valid recurrence.
11521
11531
  */
11522
- function recurringDates(startDate, endDate = new FinancialYear().endDate, frequency) {
11532
+ function recurringDates(frequency, startDate, endDate) {
11533
+ endDate = endDate ?? new FinancialYear().endDate;
11523
11534
  let duration;
11524
11535
  let amount;
11525
11536
  switch (frequency) {
@@ -11560,7 +11571,7 @@ class BudgetRule extends BudgetRule$1 {
11560
11571
  return [];
11561
11572
  }
11562
11573
  const paymentDates = this.frequency
11563
- ? recurringDates(this.startDate, this.endDate, this.frequency)
11574
+ ? recurringDates(this.frequency, this.startDate, this.endDate)
11564
11575
  : [this.startDate];
11565
11576
  return paymentDates.map((date) => plainToClass(MoneyCalendarEvent, {
11566
11577
  date: date,
@@ -11568,7 +11579,7 @@ class BudgetRule extends BudgetRule$1 {
11568
11579
  extendedProps: {
11569
11580
  id: this.id,
11570
11581
  class: BudgetRule.className,
11571
- amount: this.amount,
11582
+ amount: this.chartAccounts.isExpense() ? -this.amount : this.amount,
11572
11583
  isIncome: this.chartAccounts.isIncome(),
11573
11584
  isExpense: this.chartAccounts.isExpense(),
11574
11585
  isProperty: this.chartAccounts.isPropertyTank(),
@@ -11735,9 +11746,12 @@ class FinancialGoal extends ObservableModel {
11735
11746
  get forecast() {
11736
11747
  return this.paymentAmount * this.calculatePaymentsByDate(new Date());
11737
11748
  }
11738
- get forecastPercent() {
11749
+ get variancePercent() {
11739
11750
  return round(this.progress / this.forecast, 2);
11740
11751
  }
11752
+ get variance() {
11753
+ return round(this.progress - this.forecast);
11754
+ }
11741
11755
  /**
11742
11756
  * How much user saved so far.
11743
11757
  */
@@ -11774,6 +11788,7 @@ class FinancialGoal extends ObservableModel {
11774
11788
  return round(this.progress / this.target, 2);
11775
11789
  }
11776
11790
  getBadge() {
11791
+ const variance = new CurrencyPipe('en-AU').transform(this.variance, 'USD', 'symbol', '1.0-2');
11777
11792
  if (this.isPropertyType() && this.status === FinancialGoalStatusEnum.ACTIVE && this.progress > 0 && !this.isAchieved()) {
11778
11793
  return new Badge('Active', BadgeColorEnum.GREEN);
11779
11794
  }
@@ -11785,15 +11800,15 @@ class FinancialGoal extends ObservableModel {
11785
11800
  case this.isAchieved():
11786
11801
  return new Badge('Achieved', BadgeColorEnum.GREEN);
11787
11802
  case this.forecast === 0:
11788
- return this.progress ? new Badge(`Ahead`, BadgeColorEnum.GREEN) : new Badge(`On track`, BadgeColorEnum.PRIMARY);
11789
- case this.forecastPercent >= 1.05:
11790
- return new Badge(`Ahead by ${this.forecastPercent} %`, BadgeColorEnum.GREEN);
11791
- case this.forecastPercent >= 0.95 && this.forecastPercent <= 1.05:
11803
+ return this.progress ? new Badge(`Ahead ${this.variancePercent}`, BadgeColorEnum.GREEN) : new Badge(`On track`, BadgeColorEnum.PRIMARY);
11804
+ case this.variancePercent >= 1.05:
11805
+ return new Badge(`Ahead by ${variance}`, BadgeColorEnum.GREEN);
11806
+ case this.variancePercent >= 0.95 && this.variancePercent <= 1.05:
11792
11807
  return new Badge('On track', BadgeColorEnum.PRIMARY);
11793
- case this.forecastPercent >= 0.8 && this.forecastPercent <= 0.95:
11794
- return new Badge(`Behind by ${this.forecastPercent}%`, BadgeColorEnum.GOLD);
11808
+ case this.variancePercent >= 0.8 && this.variancePercent <= 0.95:
11809
+ return new Badge(`Behind by ${variance}`, BadgeColorEnum.GOLD);
11795
11810
  default:
11796
- return new Badge(`Behind by ${this.forecastPercent}%`, BadgeColorEnum.ERROR);
11811
+ return new Badge(`Behind by ${this.variancePercent}%`, BadgeColorEnum.ERROR);
11797
11812
  }
11798
11813
  }
11799
11814
  /**
@@ -11826,7 +11841,7 @@ class FinancialGoal extends ObservableModel {
11826
11841
  if (!this.inCalendar || this.isPropertyType()) {
11827
11842
  return [];
11828
11843
  }
11829
- const paymentDates = recurringDates(this.startDate, this.endDate, this.paymentFrequency);
11844
+ const paymentDates = recurringDates(this.paymentFrequency, this.startDate, this.endDate);
11830
11845
  return paymentDates.map(date => plainToClass(MoneyCalendarEvent, {
11831
11846
  title: this.name,
11832
11847
  date: date,