@zeniai/client-epic-state 4.19.90-beta0ND → 4.19.90-beta1ND

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.
@@ -44,19 +44,20 @@ const financeStatement = createSlice({
44
44
  updateFinanceStatementThisPeriod(draft, action) {
45
45
  const { firstMonthOfFY, coaBalances, maxNumOfPeriodsToHighlight } = action.payload;
46
46
  const { timeframe, selectedCOABalancesRange } = draft;
47
- if (coaBalances.length > 0) {
48
- const prevThisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, coaBalances);
47
+ const safeCoaBalances = coaBalances ?? [];
48
+ if (safeCoaBalances.length > 0) {
49
+ const prevThisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
49
50
  if (prevThisPeriod != null) {
50
51
  const selectedCoaBalancesRangeWithThisPeriod = {
51
52
  ...selectedCOABalancesRange,
52
53
  thisPeriod: prevThisPeriod,
53
54
  };
54
- const newThisPeriod = getMatchingThisPeriod(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, coaBalances);
55
+ const newThisPeriod = getMatchingThisPeriod(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, safeCoaBalances);
55
56
  if (newThisPeriod != null) {
56
57
  const selectionRanges = getSelectedAndHighlightedRangesForThisPeriod({
57
58
  firstMonthOfFY,
58
59
  thisPeriod: newThisPeriod,
59
- coaBalances,
60
+ coaBalances: safeCoaBalances,
60
61
  timeframe,
61
62
  maxNumOfPeriodsToSelect: maxNumOfPeriodsToHighlight,
62
63
  currentSelection: {
@@ -76,7 +77,8 @@ const financeStatement = createSlice({
76
77
  },
77
78
  updateFinanceStatementAdditionalBalancesSelection(draft, action) {
78
79
  const { firstMonthOfFY, additionalBalances, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
79
- let tempAdditionalBalances = [...additionalBalances];
80
+ const safeCoaBalances = coaBalances ?? [];
81
+ let tempAdditionalBalances = [...(additionalBalances ?? [])];
80
82
  if (additionalBalances.includes('this_period_vs_last_period') ||
81
83
  additionalBalances.includes('this_period_vs_last_period_percent')) {
82
84
  const id = tempAdditionalBalances.findIndex((balance) => balance === 'this_period_vs_last_period' ||
@@ -91,8 +93,8 @@ const financeStatement = createSlice({
91
93
  draft.isAdditionalBalancesShown =
92
94
  additionalBalances.length != 0 ? true : false;
93
95
  const { timeframe, selectedCOABalancesRange } = draft;
94
- if (coaBalances.length > 0) {
95
- const thisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, coaBalances);
96
+ if (safeCoaBalances.length > 0) {
97
+ const thisPeriod = extractThisPeriod(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
96
98
  if (thisPeriod != null) {
97
99
  const selectedCoaBalancesRangeWithThisPeriod = {
98
100
  ...selectedCOABalancesRange,
@@ -101,7 +103,7 @@ const financeStatement = createSlice({
101
103
  const selectionRanges = getSelectedAndHighlightedRangesForThisPeriod({
102
104
  firstMonthOfFY,
103
105
  thisPeriod: thisPeriod,
104
- coaBalances,
106
+ coaBalances: safeCoaBalances,
105
107
  timeframe,
106
108
  maxNumOfPeriodsToHighlight: maxNumOfPeriodsToHighlight,
107
109
  currentSelection: {
@@ -43,11 +43,15 @@ export const getFinanceStatement = createSelector((state) => state.accountState,
43
43
  if (dataAvailable != null) {
44
44
  const noFilter = newBalancesFilterForDateRange(firstMonthOfFY, financeStatementState.timeframe, dataAvailable, 'ascending_date', []);
45
45
  const profitAndLossForTimeframeTicks = getProfitAndLossReport(noFilter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
46
- if (profitAndLossForTimeframeTicks.sections.expenses != null) {
46
+ const expensesSection = profitAndLossForTimeframeTicks.sections.expenses;
47
+ const incomeSection = profitAndLossForTimeframeTicks.sections.income;
48
+ const expensesBalances = expensesSection?.balances;
49
+ const incomeBalances = incomeSection?.balances;
50
+ if (expensesSection != null) {
47
51
  balancesInTimeframe =
48
- profitAndLossForTimeframeTicks.sections.expenses.balances.length > 0
49
- ? profitAndLossForTimeframeTicks.sections['expenses'].balances
50
- : profitAndLossForTimeframeTicks.sections['income'].balances;
52
+ (expensesBalances?.length ?? 0) > 0
53
+ ? expensesBalances ?? []
54
+ : incomeBalances ?? [];
51
55
  allTimeframeTicks = balancesInTimeframe.map((balance) => toTimeframeTick(balance));
52
56
  }
53
57
  }