@zeniai/client-epic-state 5.0.19 → 5.0.21-beta0ND

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.
@@ -24,6 +24,7 @@ export interface ExpenseAutomationJESchedulesViewSelector extends SelectorView {
24
24
  ignoreStatusById: Record<JEScheduleTransactionKey, FetchStateAndError>;
25
25
  jeScheduleLocalDataById: Record<ID, JEScheduleLocalData>;
26
26
  ongoingSchedules: JEScheduledTransaction[];
27
+ pendingReviewSchedules: (JEScheduledTransaction | JEScheduledTransactionWithFailedEntries)[];
27
28
  postStatusById: Record<ID, FetchStateAndError>;
28
29
  refreshStatus: FetchStateAndError;
29
30
  resolveSchedules: JEScheduledTransactionWithFailedEntries[];
@@ -29,19 +29,33 @@ function getJEScheduleSortAccessor(sortKey) {
29
29
  case 'depCategory':
30
30
  return (s) => s.jeCredit.account?.accountName?.toLowerCase();
31
31
  case 'scheduleCategory':
32
- return (s) => s.jeScheduleType;
32
+ return (s) => s.baseTransaction.account?.accountName?.toLowerCase();
33
33
  case 'startMonth':
34
34
  return (s) => s.startDate?.valueOf();
35
35
  case 'type':
36
- return (s) => s.baseTransaction.typeOfTransaction;
36
+ return (s) => s.jeScheduleType;
37
37
  case 'amortizationPeriod':
38
38
  return (s) => s.period;
39
39
  case 'jePostingDate':
40
- return (s) => s.dayOfPostingDate;
40
+ return (s) => s.lastDayOfMonth === true
41
+ ? timePeriod_1.LAST_SCHEDULE_DAY_OF_MONTH
42
+ : (s.dayOfPostingDate ?? null);
41
43
  case 'remainingMonths':
42
- return (s) => s.period;
44
+ return (s) => {
45
+ const total = s.period ?? 0;
46
+ const posted = Array.isArray(s.scheduledJournalEntry)
47
+ ? s.scheduledJournalEntry.length
48
+ : 0;
49
+ return total - posted;
50
+ };
43
51
  case 'runningBalance':
44
- return (s) => s.balanceAsOfToday?.amount;
52
+ return (s) => {
53
+ const sje = s.scheduledJournalEntry;
54
+ if (sje != null && !Array.isArray(sje)) {
55
+ return sje.runningBalance?.amount ?? null;
56
+ }
57
+ return s.balanceAsOfToday?.amount ?? null;
58
+ };
45
59
  case 'totalAmount':
46
60
  return (s) => s.baseTransaction.amount.amount;
47
61
  case 'transactionDate':
@@ -120,6 +134,11 @@ function getExpenseAutomationJESchedulesView(state) {
120
134
  });
121
135
  });
122
136
  const resolveSchedules = sortJEScheduledTransactions(unsortedResolveSchedules, sortKey, sortOrder);
137
+ const validResolveForPending = unsortedResolveSchedules.filter((r) => jeScheduleLocalDataById[r.scheduledJournalEntry.scheduledJournalEntryID] != null);
138
+ const pendingReviewSchedules = sortJEScheduledTransactions([
139
+ ...jeScheduledTransaction.filter((schedule) => schedule.status.code === 'draft'),
140
+ ...validResolveForPending,
141
+ ], sortKey, sortOrder);
123
142
  const allSteps = monthYearPeriodId != null
124
143
  ? (0, expenseAutomationViewSelectorTypes_1.getAllSteps)(monthEndCloseChecksState, monthYearPeriodId, currentTenant.tenantId)
125
144
  : [];
@@ -143,6 +162,7 @@ function getExpenseAutomationJESchedulesView(state) {
143
162
  completedSchedules,
144
163
  draftSchedules,
145
164
  ongoingSchedules,
165
+ pendingReviewSchedules,
146
166
  resolveSchedules: resolveSchedules,
147
167
  accountSettingsView,
148
168
  postStatusById: postStatusById,
@@ -1,6 +1,20 @@
1
- import { ProfitAndLossByClassHorizontalReport } from './profitAndLossClassesByClassHorizontalSelectorTypes';
1
+ import { COABalance } from '../../commonStateTypes/coaBalance/coaBalance';
2
+ import { HorizontalAccountRow, ProfitAndLossByClassHorizontalReport } from './profitAndLossClassesByClassHorizontalSelectorTypes';
2
3
  /**
3
4
  * Populates `sectionHeaderBalancesSlice`, and per-account `accountReportData`, so the
4
5
  * web layer only maps selector output to tree nodes.
5
6
  */
6
7
  export declare function enrichProfitAndLossByClassHorizontalReport(report: ProfitAndLossByClassHorizontalReport): void;
8
+ /**
9
+ * Sum balances across descendant accounts (recursive).
10
+ *
11
+ * Parent rows in the horizontal pivot only carry their own direct postings
12
+ * (zero for "container" accounts), so callers rendering "Total {parent}" rows
13
+ * must aggregate from descendants to get the real per-class totals.
14
+ *
15
+ * Returns one `COABalance` per class column + total (same shape as the
16
+ * enriched `balancesInTimeframe.balances`), with `amount` summed and `type`
17
+ * set to `default_with_null_balance` for zeros. Returns `[]` when no
18
+ * descendants have enriched data.
19
+ */
20
+ export declare function aggregateHorizontalDescendantBalances(accounts: readonly HorizontalAccountRow[], childIndices: readonly number[], childrenByParent: Readonly<Record<number, readonly number[]>>): COABalance[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enrichProfitAndLossByClassHorizontalReport = enrichProfitAndLossByClassHorizontalReport;
4
+ exports.aggregateHorizontalDescendantBalances = aggregateHorizontalDescendantBalances;
4
5
  const currencyHelper_1 = require("../../commonStateTypes/currencyHelper");
5
6
  const horizontalSectionEmptyBalancesSlice_1 = require("./horizontalSectionEmptyBalancesSlice");
6
7
  const profitAndLossClassesByClassHorizontalSelectorTypes_1 = require("./profitAndLossClassesByClassHorizontalSelectorTypes");
@@ -118,6 +119,48 @@ function buildHorizontalClassColumnBalancesSlice(report, classAmounts, totalAmou
118
119
  },
119
120
  };
120
121
  }
122
+ /**
123
+ * Sum balances across descendant accounts (recursive).
124
+ *
125
+ * Parent rows in the horizontal pivot only carry their own direct postings
126
+ * (zero for "container" accounts), so callers rendering "Total {parent}" rows
127
+ * must aggregate from descendants to get the real per-class totals.
128
+ *
129
+ * Returns one `COABalance` per class column + total (same shape as the
130
+ * enriched `balancesInTimeframe.balances`), with `amount` summed and `type`
131
+ * set to `default_with_null_balance` for zeros. Returns `[]` when no
132
+ * descendants have enriched data.
133
+ */
134
+ function aggregateHorizontalDescendantBalances(accounts, childIndices, childrenByParent) {
135
+ let template;
136
+ const sums = new Map();
137
+ const walk = (idx) => {
138
+ const childRow = accounts[idx];
139
+ const childBalances = childRow?.accountReportData?.balancesInTimeframe.balances;
140
+ if (childBalances != null) {
141
+ if (template == null) {
142
+ template = childBalances;
143
+ }
144
+ childBalances.forEach((b, i) => {
145
+ sums.set(i, (sums.get(i) ?? 0) + (b.balance.amount ?? 0));
146
+ });
147
+ const grandChildren = childrenByParent[idx] ?? [];
148
+ grandChildren.forEach(walk);
149
+ }
150
+ };
151
+ childIndices.forEach(walk);
152
+ if (template == null) {
153
+ return [];
154
+ }
155
+ return template.map((tpl, i) => {
156
+ const amount = sums.get(i) ?? 0;
157
+ return {
158
+ ...tpl,
159
+ balance: { ...tpl.balance, amount },
160
+ type: amount === 0 ? 'default_with_null_balance' : 'default',
161
+ };
162
+ });
163
+ }
121
164
  /**
122
165
  * Parent index per DFS row — O(n). Matches the scan in the former
123
166
  * `findHorizontalAccountParentIndex` (depth &lt;= 2 rows have no parent).
@@ -53,8 +53,13 @@ const sortedJETransactionsView = (jeTransactions, sortKey, sortOrder) => {
53
53
  return jeTransaction.endDate != null
54
54
  ? jeTransaction.endDate.valueOf()
55
55
  : null;
56
- case 'months':
57
- return jeTransaction.period ?? null;
56
+ case 'months': {
57
+ const total = jeTransaction.period ?? 0;
58
+ const posted = Array.isArray(jeTransaction.scheduledJournalEntry)
59
+ ? jeTransaction.scheduledJournalEntry.length
60
+ : 0;
61
+ return total - posted;
62
+ }
58
63
  case 'transactionType':
59
64
  return jeTransaction.baseTransaction.type.toLowerCase();
60
65
  case 'status':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.19",
3
+ "version": "5.0.21-beta0ND",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",