taxtank-core 2.0.71 → 2.0.73

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.
@@ -11556,6 +11556,9 @@ class FinancialGoal extends AbstractModel {
11556
11556
  isCompleted() {
11557
11557
  return this.status === FinancialGoalStatusEnum.COMPLETE;
11558
11558
  }
11559
+ isAchieved() {
11560
+ return this.progress >= this.target;
11561
+ }
11559
11562
  isPropertyType() {
11560
11563
  return [FinancialGoalTypeEnum.PROPERTY_EQUITY, FinancialGoalTypeEnum.PROPERTY_LVR].includes(this.type);
11561
11564
  }
@@ -11575,41 +11578,50 @@ class FinancialGoal extends AbstractModel {
11575
11578
  * How much user saved so far.
11576
11579
  */
11577
11580
  get progress() {
11578
- if (this.isPropertyType()) {
11579
- return 0;
11581
+ let progress = this.currentValue - this.initialValue;
11582
+ if (this.isLvr()) {
11583
+ progress = this.initialValue - this.currentValue;
11580
11584
  }
11581
- return this.isCompleted()
11582
- ? Math.abs(this.finalValue - this.initialValue)
11583
- : Math.abs(this.bankAccount.currentBalance - this.initialValue);
11585
+ return round(progress, 2);
11584
11586
  }
11585
11587
  /**
11586
11588
  * How much is left to reach the goal from the current balance.
11587
11589
  */
11588
11590
  get remaining() {
11589
- return this.isCompleted() ? 0 : this.target - this.progress;
11591
+ if (this.isCompleted() || this.isAchieved()) {
11592
+ return 0;
11593
+ }
11594
+ return round(this.target - this.progress, 2);
11590
11595
  }
11591
11596
  /**
11592
11597
  * How much needs to deposit to achieve the goal from the start
11593
11598
  */
11594
11599
  get target() {
11595
- return Math.abs(this.targetValue - this.initialValue);
11600
+ let target = this.targetValue - this.initialValue;
11601
+ if (this.isLvr()) {
11602
+ target = this.initialValue - this.targetValue;
11603
+ }
11604
+ return round(target, 2);
11596
11605
  }
11597
11606
  /**
11598
11607
  * How much of the goal is reached in percents.
11599
11608
  */
11600
11609
  get progressPercent() {
11601
- return this.progress / this.target;
11610
+ return round(this.progress / this.target, 2);
11602
11611
  }
11603
11612
  getBadge() {
11613
+ if (this.isPropertyType() && this.status === FinancialGoalStatusEnum.ACTIVE && this.progress > 0 && !this.isAchieved()) {
11614
+ return new Badge('Active', BadgeColorEnum.GREEN);
11615
+ }
11604
11616
  switch (true) {
11605
11617
  case this.status === FinancialGoalStatusEnum.PAUSE:
11606
11618
  return new Badge('Paused', BadgeColorEnum.GOLD);
11607
11619
  case this.status === FinancialGoalStatusEnum.COMPLETE:
11608
11620
  return new Badge('Completed', BadgeColorEnum.GREEN);
11621
+ case this.isAchieved():
11622
+ return new Badge('Achieved', BadgeColorEnum.GREEN);
11609
11623
  case this.forecast === 0:
11610
11624
  return this.progress ? new Badge(`Ahead`, BadgeColorEnum.GREEN) : new Badge(`On track`, BadgeColorEnum.PRIMARY);
11611
- case this.progress >= this.target:
11612
- return new Badge('Achieved', BadgeColorEnum.GREEN);
11613
11625
  case this.forecastPercent >= 1.05:
11614
11626
  return new Badge(`Ahead by ${this.forecastPercent} %`, BadgeColorEnum.GREEN);
11615
11627
  case this.forecastPercent >= 0.95 && this.forecastPercent <= 1.05: