taxtank-core 0.31.55 → 0.31.59

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.
@@ -1558,11 +1558,14 @@ class FinancialYear {
1558
1558
  this.year = date instanceof Date ? FinancialYear.toFinYear(date) : date;
1559
1559
  }
1560
1560
  else {
1561
- this.year = +localStorage.getItem('financialYear') || FinancialYear.toFinYear(new Date());
1561
+ this.year = FinancialYear.year || FinancialYear.toFinYear(new Date());
1562
1562
  }
1563
1563
  this.setStartDate(this.year);
1564
1564
  this.setEndDate(this.year);
1565
1565
  }
1566
+ static isCurrent(year = FinancialYear.year) {
1567
+ return FinancialYear.toFinYear(new Date()) === year;
1568
+ }
1566
1569
  includes(date) {
1567
1570
  return this.year === new FinancialYear(date).year;
1568
1571
  }
@@ -1600,6 +1603,7 @@ class FinancialYear {
1600
1603
  FinancialYear.weeksInYear = 52;
1601
1604
  FinancialYear.monthsInYear = 12;
1602
1605
  FinancialYear.startMonthIndex = 6;
1606
+ FinancialYear.year = +localStorage.getItem('financialYear');
1603
1607
 
1604
1608
  /**
1605
1609
  * @TODO move to pipe/translation
@@ -9525,18 +9529,20 @@ class BankAccount extends BankAccount$1 {
9525
9529
  get partialAccountNumber() {
9526
9530
  return `xxxx${this.accountNumber.slice(-4)}`;
9527
9531
  }
9532
+ get balance() {
9533
+ return FinancialYear.isCurrent() ? this.currentBalance : this.getOpeningBalance(FinancialYear.year + 1);
9534
+ }
9528
9535
  /**
9529
9536
  * Get current opening balance amount
9530
9537
  */
9531
- getOpeningBalance() {
9532
- return this.getCurrentYearBalance()?.openingBalance || 0;
9538
+ getOpeningBalance(year = FinancialYear.year) {
9539
+ return this.getBalanceByYear(year)?.openingBalance || 0;
9533
9540
  }
9534
9541
  /**
9535
9542
  * Get bank account balance for current financial year
9536
9543
  */
9537
- getCurrentYearBalance() {
9538
- const currentFinYear = new FinancialYear().year;
9539
- return this.balances.find((balance) => balance.financialYear === currentFinYear);
9544
+ getBalanceByYear(year) {
9545
+ return this.balances.find((balance) => balance.financialYear === year);
9540
9546
  }
9541
9547
  /**
9542
9548
  * check if bank account type is one of savings accounts
@@ -13001,7 +13007,8 @@ class SoleForecastService extends RestService {
13001
13007
  .subscribe((incomeSources) => {
13002
13008
  const soleForecasts = this.assignSoleForecasts(incomeSources);
13003
13009
  if (soleForecasts.length) {
13004
- this.updateBatch(soleForecasts).subscribe((updatedSoleForecasts) => {
13010
+ const method = soleForecasts[0].id ? 'updateBatch' : 'addBatch';
13011
+ this[method](soleForecasts).subscribe((updatedSoleForecasts) => {
13005
13012
  this.eventDispatcherService
13006
13013
  .dispatch(new AppEvent(AppEventTypeEnum.INCOME_SOURCES_FORECASTS_UPDATED, updatedSoleForecasts));
13007
13014
  });