@zeniai/client-epic-state 4.19.90 → 4.19.91-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.
- package/lib/entity/chargeCardTransaction/chargeCardTransaction.d.ts +1 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +1 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +10 -5
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +2 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +2 -2
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +1 -2
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +7 -3
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +3 -1
- package/lib/entity/reimbursement/reimbursementPayload.d.ts +1 -1
- package/lib/entity/reimbursement/reimbursementPayload.js +1 -1
- package/lib/entity/transaction/transactionReducer.js +3 -2
- package/lib/entity/transaction/transactionSelector.d.ts +2 -2
- package/lib/entity/transaction/transactionState.d.ts +3 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +10 -5
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +3 -3
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +1 -0
- package/lib/esm/entity/reimbursement/reimbursementPayload.js +1 -1
- package/lib/esm/entity/transaction/transactionReducer.js +3 -2
- package/lib/esm/index.js +5 -4
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +4 -12
- package/lib/esm/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/esm/view/financeStatement/financeStatementSelector.js +13 -4
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +281 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +1 -0
- package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +5 -1
- package/lib/esm/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -7
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +2 -7
- package/lib/index.d.ts +7 -5
- package/lib/index.js +29 -25
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +11 -11
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +3 -11
- package/lib/view/financeStatement/financeStatementReducer.js +11 -8
- package/lib/view/financeStatement/financeStatementSelector.d.ts +2 -0
- package/lib/view/financeStatement/financeStatementSelector.js +13 -4
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.d.ts +13 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js +285 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts +57 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js +2 -0
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.d.ts +4 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewReducer.js +6 -2
- package/lib/view/profitAndLossClassesView/profitAndLossClassesViewState.d.ts +2 -0
- package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +2 -7
- package/lib/view/scheduleView/scheduleDetailView/scheduleDetailReducer.d.ts +4 -4
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +1 -6
- package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
- package/package.json +2 -2
package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector.js
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { toAmountWC } from '../../commonStateTypes/amount';
|
|
2
|
+
import { getSectionClassesViewReport } from '../../entity/sectionClassesViewV2/sectionClassesViewSelector';
|
|
3
|
+
import { ALL_PANDL_REPORT_VIEW_SECTION_IDS, } from './profitAndLossClassesViewSelectorTypes';
|
|
4
|
+
const DEFAULT_CURRENCY = { currencyCode: 'USD', currencySymbol: '$' };
|
|
5
|
+
export const profitAndLossHorizontalIdsInOrder = [
|
|
6
|
+
'income',
|
|
7
|
+
'cogs',
|
|
8
|
+
'grossProfit',
|
|
9
|
+
'expenses',
|
|
10
|
+
'earningsBeforeInterestAndTax',
|
|
11
|
+
'otherIncome',
|
|
12
|
+
'otherExpenses',
|
|
13
|
+
'netOtherIncome',
|
|
14
|
+
'netIncome',
|
|
15
|
+
];
|
|
16
|
+
const SECTION_TITLES = {
|
|
17
|
+
income: 'Income',
|
|
18
|
+
cogs: 'Cost of Goods Sold',
|
|
19
|
+
grossProfit: 'Gross Profit',
|
|
20
|
+
expenses: 'Expenses',
|
|
21
|
+
earningsBeforeInterestAndTax: 'Net Operating Income',
|
|
22
|
+
otherIncome: 'Other Income',
|
|
23
|
+
otherExpenses: 'Other Expenses',
|
|
24
|
+
netOtherIncome: 'Net Other Income',
|
|
25
|
+
netIncome: 'Net Income',
|
|
26
|
+
};
|
|
27
|
+
export const getProfitAndLossClassesHorizontalView = (filter, accountState, classState, sectionsState, profitAndLossClassesViewState, selectedPeriod) => {
|
|
28
|
+
const fetchState = reduceFetchState([
|
|
29
|
+
profitAndLossClassesViewState.fetchState.month,
|
|
30
|
+
profitAndLossClassesViewState.fetchState.quarter,
|
|
31
|
+
profitAndLossClassesViewState.fetchState.year,
|
|
32
|
+
]);
|
|
33
|
+
const reportId = 'profit_and_loss_by_classes';
|
|
34
|
+
// Build class columns from the class hierarchy (top-level only)
|
|
35
|
+
const classColumns = buildClassColumns(profitAndLossClassesViewState.classHierarchy, profitAndLossClassesViewState.uiState.classesToFilterOut);
|
|
36
|
+
const sections = {};
|
|
37
|
+
const calculatedSections = {};
|
|
38
|
+
if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
|
|
39
|
+
// Get section reports using existing selector infrastructure
|
|
40
|
+
const sectionReports = {};
|
|
41
|
+
ALL_PANDL_REPORT_VIEW_SECTION_IDS.forEach((sectionId) => {
|
|
42
|
+
sectionReports[sectionId] = getSectionClassesViewReport(accountState, classState, sectionsState, { reportId, sectionId }, filter);
|
|
43
|
+
});
|
|
44
|
+
// Pivot each section from class→account to account→class
|
|
45
|
+
const sectionIds = [
|
|
46
|
+
'income',
|
|
47
|
+
'cogs',
|
|
48
|
+
'expenses',
|
|
49
|
+
'otherIncome',
|
|
50
|
+
'otherExpenses',
|
|
51
|
+
];
|
|
52
|
+
sectionIds.forEach((sectionId) => {
|
|
53
|
+
const sectionReport = sectionReports[sectionId];
|
|
54
|
+
if (sectionReport != null) {
|
|
55
|
+
sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, SECTION_TITLES[sectionId] ?? sectionId);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
// Calculate derived sections
|
|
59
|
+
const incomeSection = sections['income'];
|
|
60
|
+
const cogsSection = sections['cogs'];
|
|
61
|
+
const expensesSection = sections['expenses'];
|
|
62
|
+
const otherIncomeSection = sections['otherIncome'];
|
|
63
|
+
const otherExpensesSection = sections['otherExpenses'];
|
|
64
|
+
// Gross Profit = Income - COGS
|
|
65
|
+
if (incomeSection != null && cogsSection != null) {
|
|
66
|
+
calculatedSections['grossProfit'] = computeCalculatedSection(incomeSection.classTotals, cogsSection.classTotals, incomeSection.sectionTotal, cogsSection.sectionTotal, 'subtract', SECTION_TITLES['grossProfit']);
|
|
67
|
+
}
|
|
68
|
+
// EBIT = Gross Profit - Expenses
|
|
69
|
+
const grossProfit = calculatedSections['grossProfit'];
|
|
70
|
+
if (grossProfit != null && expensesSection != null) {
|
|
71
|
+
calculatedSections['earningsBeforeInterestAndTax'] =
|
|
72
|
+
computeCalculatedSection(grossProfit.classTotals, expensesSection.classTotals, grossProfit.sectionTotal, expensesSection.sectionTotal, 'subtract', SECTION_TITLES['earningsBeforeInterestAndTax']);
|
|
73
|
+
}
|
|
74
|
+
// Net Other Income = Other Income - Other Expenses
|
|
75
|
+
if (otherIncomeSection != null && otherExpensesSection != null) {
|
|
76
|
+
calculatedSections['netOtherIncome'] = computeCalculatedSection(otherIncomeSection.classTotals, otherExpensesSection.classTotals, otherIncomeSection.sectionTotal, otherExpensesSection.sectionTotal, 'subtract', SECTION_TITLES['netOtherIncome']);
|
|
77
|
+
}
|
|
78
|
+
// Net Income = EBIT + Net Other Income
|
|
79
|
+
const ebit = calculatedSections['earningsBeforeInterestAndTax'];
|
|
80
|
+
const netOtherIncome = calculatedSections['netOtherIncome'];
|
|
81
|
+
if (ebit != null && netOtherIncome != null) {
|
|
82
|
+
calculatedSections['netIncome'] = computeCalculatedSection(ebit.classTotals, netOtherIncome.classTotals, ebit.sectionTotal, netOtherIncome.sectionTotal, 'add', SECTION_TITLES['netIncome']);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Build synthetic header COABalances for rendering class names as column headers
|
|
86
|
+
const headerBalances = buildHeaderBalances(classColumns, filter.timeframe, selectedPeriod);
|
|
87
|
+
return {
|
|
88
|
+
reportId,
|
|
89
|
+
reportTitle: 'Profit and Loss by Class',
|
|
90
|
+
firstMonthOfFY: profitAndLossClassesViewState.firstMonthOfFY,
|
|
91
|
+
fetchState: fetchState.fetchState,
|
|
92
|
+
bookCloseDate: profitAndLossClassesViewState.bookCloseDate,
|
|
93
|
+
dataAvailable: profitAndLossClassesViewState.dataAvailable,
|
|
94
|
+
selectedPeriod,
|
|
95
|
+
classColumns,
|
|
96
|
+
sections,
|
|
97
|
+
calculatedSections,
|
|
98
|
+
idsInOrder: profitAndLossHorizontalIdsInOrder,
|
|
99
|
+
uiState: profitAndLossClassesViewState.uiState,
|
|
100
|
+
headerBalances,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Build column definitions from class hierarchy (top-level classes only).
|
|
105
|
+
*/
|
|
106
|
+
function buildClassColumns(classHierarchy, classesToFilterOut) {
|
|
107
|
+
return classHierarchy
|
|
108
|
+
.filter((c) => !classesToFilterOut.some((filteredId) => filteredId[0] === c.classId[0]))
|
|
109
|
+
.map((c) => ({
|
|
110
|
+
classId: c.classId[0],
|
|
111
|
+
className: c.className,
|
|
112
|
+
nestedClassId: c.classId,
|
|
113
|
+
qboId: c.qboId,
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Pivot a section from class→account→balances to account→class→balance (single period).
|
|
118
|
+
*/
|
|
119
|
+
function pivotSectionToHorizontal(section, classColumns, title) {
|
|
120
|
+
// Map: accountId -> { accountName, classId -> balance }
|
|
121
|
+
const accountMap = new Map();
|
|
122
|
+
// Also track class totals
|
|
123
|
+
const classTotalMap = new Map();
|
|
124
|
+
classColumns.forEach((col) => classTotalMap.set(col.classId, 0));
|
|
125
|
+
// Iterate over each class in the section
|
|
126
|
+
section.classes.forEach((classReport) => {
|
|
127
|
+
const classId = classReport.id[0];
|
|
128
|
+
// Only process classes that are in our columns
|
|
129
|
+
if (!classColumns.some((col) => col.classId === classId)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
// Sum all sliced period balances (same slice as vertical columns; multi-period = range total)
|
|
133
|
+
const classBalance = sumBalancesInSlice(classReport.childrenBalancesTotal.balances);
|
|
134
|
+
classTotalMap.set(classId, classBalance);
|
|
135
|
+
// Iterate through accounts in this class
|
|
136
|
+
collectAccountsFromClass(classReport, classId, accountMap);
|
|
137
|
+
});
|
|
138
|
+
// Build account rows
|
|
139
|
+
const accounts = [];
|
|
140
|
+
accountMap.forEach((accountData, accountId) => {
|
|
141
|
+
const classBalances = classColumns.map((col) => ({
|
|
142
|
+
classId: col.classId,
|
|
143
|
+
balance: toAmountWC(accountData.classBalances.get(col.classId) ?? 0, DEFAULT_CURRENCY),
|
|
144
|
+
}));
|
|
145
|
+
const rowTotal = classBalances.reduce((sum, cb) => sum + cb.balance.amount, 0);
|
|
146
|
+
accounts.push({
|
|
147
|
+
accountId,
|
|
148
|
+
accountName: accountData.accountName,
|
|
149
|
+
classBalances,
|
|
150
|
+
rowTotal: toAmountWC(rowTotal, DEFAULT_CURRENCY),
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
// Build class totals
|
|
154
|
+
const classTotals = classColumns.map((col) => ({
|
|
155
|
+
classId: col.classId,
|
|
156
|
+
balance: toAmountWC(classTotalMap.get(col.classId) ?? 0, DEFAULT_CURRENCY),
|
|
157
|
+
}));
|
|
158
|
+
const sectionTotal = classTotals.reduce((sum, ct) => sum + ct.balance.amount, 0);
|
|
159
|
+
return {
|
|
160
|
+
title,
|
|
161
|
+
accounts,
|
|
162
|
+
classTotals,
|
|
163
|
+
sectionTotal: toAmountWC(sectionTotal, DEFAULT_CURRENCY),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Recursively collect account balances from a NestedClassReportV2 into accountMap.
|
|
168
|
+
*/
|
|
169
|
+
function collectAccountsFromClass(classReport, classId, accountMap) {
|
|
170
|
+
// Process accounts directly on this class
|
|
171
|
+
classReport.class.accounts.forEach((nestedAccount) => {
|
|
172
|
+
collectAccountsFromNestedAccount(nestedAccount, classId, accountMap);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Recursively collect accounts from NestedAccountReport (handles sub-accounts).
|
|
177
|
+
*/
|
|
178
|
+
function collectAccountsFromNestedAccount(nestedAccount, classId, accountMap) {
|
|
179
|
+
const accountId = nestedAccount.account.accountId;
|
|
180
|
+
const accountName = nestedAccount.account.accountName;
|
|
181
|
+
const balance = sumBalancesInSlice(nestedAccount.account.balancesInTimeframe.balances);
|
|
182
|
+
if (!accountMap.has(accountId)) {
|
|
183
|
+
accountMap.set(accountId, {
|
|
184
|
+
accountName,
|
|
185
|
+
classBalances: new Map(),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const accountData = accountMap.get(accountId);
|
|
189
|
+
if (accountData == null) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const existing = accountData.classBalances.get(classId) ?? 0;
|
|
193
|
+
accountData.classBalances.set(classId, existing + balance);
|
|
194
|
+
// Process sub-accounts
|
|
195
|
+
nestedAccount.children.forEach((child) => {
|
|
196
|
+
collectAccountsFromNestedAccount(child, classId, accountMap);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Total amount for the current report slice. `balances` is already narrowed by
|
|
201
|
+
* `getCOABalances` / `sliceCOABalances` to the selected range; summing matches
|
|
202
|
+
* multi-period selections and avoids mismatches when `thisPeriod` does not
|
|
203
|
+
* align with a row (e.g. slice fallback) or when several period rows are shown.
|
|
204
|
+
*/
|
|
205
|
+
function sumBalancesInSlice(balances) {
|
|
206
|
+
let sum = 0;
|
|
207
|
+
for (const bal of balances) {
|
|
208
|
+
const b = bal;
|
|
209
|
+
sum += b.balance?.amount ?? 0;
|
|
210
|
+
}
|
|
211
|
+
return sum;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Compute a calculated section by adding or subtracting two sets of class totals.
|
|
215
|
+
*/
|
|
216
|
+
function computeCalculatedSection(aTotals, bTotals, aTotal, bTotal, operation, title) {
|
|
217
|
+
const classTotals = aTotals.map((a) => {
|
|
218
|
+
const bMatch = bTotals.find((b) => b.classId === a.classId);
|
|
219
|
+
const bAmount = bMatch?.balance.amount ?? 0;
|
|
220
|
+
const resultAmount = operation === 'add'
|
|
221
|
+
? a.balance.amount + bAmount
|
|
222
|
+
: a.balance.amount - bAmount;
|
|
223
|
+
return {
|
|
224
|
+
classId: a.classId,
|
|
225
|
+
balance: toAmountWC(resultAmount, DEFAULT_CURRENCY),
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
const sectionTotalAmount = operation === 'add'
|
|
229
|
+
? aTotal.amount + bTotal.amount
|
|
230
|
+
: aTotal.amount - bTotal.amount;
|
|
231
|
+
return {
|
|
232
|
+
title,
|
|
233
|
+
classTotals,
|
|
234
|
+
sectionTotal: toAmountWC(sectionTotalAmount, DEFAULT_CURRENCY),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Build synthetic COABalance array for header rendering.
|
|
239
|
+
* One entry per class column + one for "Total".
|
|
240
|
+
*/
|
|
241
|
+
function buildHeaderBalances(classColumns, timeframe, selectedPeriod) {
|
|
242
|
+
if (selectedPeriod == null) {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
const { endDate, startDate } = selectedPeriod;
|
|
246
|
+
const balances = classColumns.map((col) => ({
|
|
247
|
+
balance: toAmountWC(0, DEFAULT_CURRENCY),
|
|
248
|
+
balanceTimeFrame: timeframe,
|
|
249
|
+
endDate,
|
|
250
|
+
startDate,
|
|
251
|
+
type: 'default',
|
|
252
|
+
label: col.className,
|
|
253
|
+
}));
|
|
254
|
+
// Add a "Total" column
|
|
255
|
+
balances.push({
|
|
256
|
+
balance: toAmountWC(0, DEFAULT_CURRENCY),
|
|
257
|
+
balanceTimeFrame: timeframe,
|
|
258
|
+
endDate,
|
|
259
|
+
startDate,
|
|
260
|
+
type: 'default',
|
|
261
|
+
label: 'Total',
|
|
262
|
+
});
|
|
263
|
+
return balances;
|
|
264
|
+
}
|
|
265
|
+
function reduceFetchState(fetchStateList) {
|
|
266
|
+
const isAnyProgress = fetchStateList.some((s) => s.fetchState === 'In-Progress');
|
|
267
|
+
const isAllCompleted = fetchStateList.every((s) => s.fetchState === 'Completed');
|
|
268
|
+
const isAnyError = fetchStateList.some((s) => s.fetchState === 'Error');
|
|
269
|
+
const error = fetchStateList.find((s) => s.error != null)?.error;
|
|
270
|
+
let fetchState = 'Not-Started';
|
|
271
|
+
if (isAnyProgress) {
|
|
272
|
+
fetchState = 'In-Progress';
|
|
273
|
+
}
|
|
274
|
+
else if (isAllCompleted) {
|
|
275
|
+
fetchState = 'Completed';
|
|
276
|
+
}
|
|
277
|
+
else if (isAnyError) {
|
|
278
|
+
fetchState = 'Error';
|
|
279
|
+
}
|
|
280
|
+
return { fetchState, error };
|
|
281
|
+
}
|
package/lib/esm/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -23,6 +23,7 @@ export const initialState = {
|
|
|
23
23
|
nodeCollapseState: {},
|
|
24
24
|
scrollPosition: undefined,
|
|
25
25
|
accountViewMode: 'account_group',
|
|
26
|
+
classViewLayout: 'vertical',
|
|
26
27
|
classesToFilterOut: [],
|
|
27
28
|
},
|
|
28
29
|
firstMonthOfFY: 1,
|
|
@@ -94,6 +95,9 @@ const profitAndLossClassesView = createSlice({
|
|
|
94
95
|
updateAccountViewMode(draft, action) {
|
|
95
96
|
draft.uiState.accountViewMode = action.payload.viewMode;
|
|
96
97
|
},
|
|
98
|
+
updateClassViewLayout(draft, action) {
|
|
99
|
+
draft.uiState.classViewLayout = action.payload.classViewLayout;
|
|
100
|
+
},
|
|
97
101
|
resetProfitAndLossClassesNodeCollapseState(draft) {
|
|
98
102
|
draft.uiState.nodeCollapseState = {};
|
|
99
103
|
},
|
|
@@ -102,7 +106,7 @@ const profitAndLossClassesView = createSlice({
|
|
|
102
106
|
},
|
|
103
107
|
},
|
|
104
108
|
});
|
|
105
|
-
export const { fetchProfitAndLossClassesView, fetchProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesViewFailure, updateClassesToFilterOut, updateProfitAndLossClassesViewUIState, updateAccountViewMode, resetProfitAndLossClassesNodeCollapseState, clearProfitAndLossClassesView, } = profitAndLossClassesView.actions;
|
|
109
|
+
export const { fetchProfitAndLossClassesView, fetchProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesView, updateProfitAndLossForTimeframeClassesViewFailure, updateClassesToFilterOut, updateProfitAndLossClassesViewUIState, updateAccountViewMode, updateClassViewLayout, resetProfitAndLossClassesNodeCollapseState, clearProfitAndLossClassesView, } = profitAndLossClassesView.actions;
|
|
106
110
|
export default profitAndLossClassesView.reducer;
|
|
107
111
|
const doUpdatedProfitAndLossClassesView = (draft, timeframe, pandLReport) => {
|
|
108
112
|
const report = mapReportPayloadV2ToReportV2(pandLReport.report);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { from, of } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { getJEScheduleTransactionDetailKeyPayload, } from '../../../../entity/jeSchedules/jeSchedulesPayload';
|
|
3
4
|
import { updateJESchedules, updateJESchedulesDetails, } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
-
import { toTransactionType } from '../../../../entity/transaction/stateTypes/transactionType';
|
|
5
5
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
6
|
-
import { getZeniTransactionDetailKey } from '../../../transactionDetail/transactionDetailState';
|
|
7
6
|
import { createNewSchedules, fetchScheduleDetails, initializeScheduleDetailLocalData, saveScheduleDetailsSuccessOrFailure, updateScheduleDetailsFailure, updateScheduleDetailsSuccess, updateSelectedJEScheduleKey, } from '../scheduleDetailReducer';
|
|
8
7
|
export const fetchScheduleDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchScheduleDetails.match), mergeMap((action) => {
|
|
9
8
|
const updateActions = [];
|
|
@@ -24,11 +23,7 @@ export const fetchScheduleDetailsEpic = (actions$, state$, zeniAPI) => actions$.
|
|
|
24
23
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${selectedJeScheduleDetailId}?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
25
24
|
.pipe(mergeMap((response) => {
|
|
26
25
|
if (isSuccessResponse(response) && response.data != null) {
|
|
27
|
-
const
|
|
28
|
-
const selectedJEScheduleKey = getZeniTransactionDetailKey({
|
|
29
|
-
id: transactionData.transaction_id,
|
|
30
|
-
type: toTransactionType(transactionData.transaction_type),
|
|
31
|
-
});
|
|
26
|
+
const selectedJEScheduleKey = getJEScheduleTransactionDetailKeyPayload(response.data.je_schedules[0].base_transaction);
|
|
32
27
|
updateActions.push(updateJESchedules(response.data.je_schedules), updateSelectedJEScheduleKey({ selectedJEScheduleKey }), updateJESchedulesDetails(response.data.je_schedules, response.data.scheduled_journal_entries), saveScheduleDetailsSuccessOrFailure('Not-Started'), initializeScheduleDetailLocalData(scheduleType, selectedJEScheduleKey, selectedJeScheduleDetailId), updateScheduleDetailsSuccess());
|
|
33
28
|
if (response.data.je_schedules[0].status.code === 'draft' &&
|
|
34
29
|
isCompleteJEScheduleFormDataPresent(response.data.je_schedules[0])) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { createSlice } from '@reduxjs/toolkit';
|
|
2
|
-
import { getJEScheduleKey, } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
3
|
-
import { toTransactionID } from '../../../entity/transaction/payloadTypes/transactionIDPayload';
|
|
4
|
-
import { getZeniTransactionDetailKey } from '../../transactionDetail/transactionDetailState';
|
|
2
|
+
import { getJEScheduleKey, getJEScheduleTransactionDetailKeyPayload, } from '../../../entity/jeSchedules/jeSchedulesPayload';
|
|
5
3
|
import { getDefaultSelectedTimeframeForScheduleType } from './scheduleListHelper';
|
|
6
4
|
import { getScheduleListKey, } from './scheduleListTypes';
|
|
7
5
|
export const initialUIState = {
|
|
@@ -379,10 +377,7 @@ export default scheduleListView.reducer;
|
|
|
379
377
|
function doUpdateScheduleList(draft, payload, scheduleType, selectedTimeframe, selectedCategoryId) {
|
|
380
378
|
if (scheduleType !== 'accrued_expenses') {
|
|
381
379
|
const state = getState(draft, scheduleType);
|
|
382
|
-
const jeScheduleTransactionKeys = payload.map((schedules) =>
|
|
383
|
-
const transactionID = toTransactionID(schedules.base_transaction);
|
|
384
|
-
return getZeniTransactionDetailKey(transactionID);
|
|
385
|
-
});
|
|
380
|
+
const jeScheduleTransactionKeys = payload.map((schedules) => getJEScheduleTransactionDetailKeyPayload(schedules.base_transaction));
|
|
386
381
|
state.selectedCategoryId = selectedCategoryId;
|
|
387
382
|
state.selectedTimeframe = selectedTimeframe;
|
|
388
383
|
const key = getScheduleListKey(selectedCategoryId, selectedTimeframe);
|
package/lib/index.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ import { TrendChangeType } from './entity/insights/insightPayload';
|
|
|
91
91
|
import { Insight } from './entity/insights/insightState';
|
|
92
92
|
import { InsightSummary } from './entity/insights/insightSummary';
|
|
93
93
|
import { JEAccruedSchedule, JEScheduledTransaction, ScheduledJournalEntry } from './entity/jeSchedules/jeSchedulesSelector';
|
|
94
|
-
import { ALL_SCHEDULES_TYPES, JEScheduleKey, JEScheduleTransactionKey, JournalEntryErrorCodeType, ScheduleJournalEntryStatusCodeType, ScheduleStatusCodeType, ScheduleTypes, toScheduleTypesType, toScheduleTypesTypeStrict } from './entity/jeSchedules/jeSchedulesTypes';
|
|
94
|
+
import { ALL_SCHEDULES_TYPES, JEScheduleKey, JEScheduleTransactionKey, JournalEntryErrorCodeType, ScheduleJournalEntryStatusCodeType, ScheduleStatusCodeType, ScheduleTransactionID, ScheduleTypes, getJEScheduleTransactionKey, toScheduleTypesType, toScheduleTypesTypeStrict } from './entity/jeSchedules/jeSchedulesTypes';
|
|
95
95
|
import { Merchant } from './entity/merchant/merchant';
|
|
96
96
|
import { ALL_MONTH_END_CLOSE_CHECKS_FREQUENCY, MonthCloseCheckMetrics, MonthEndAuditSummary, MonthEndCloseCheck, MonthEndCloseCheckFrequency } from './entity/monthEndCloseChecks/monthEndCloseChecksState';
|
|
97
97
|
import { updateCommentsNotifications, updateCommentsNotificationsStatuses } from './entity/notification/notificationReducer';
|
|
@@ -346,10 +346,12 @@ import { PeopleViewSortKey } from './view/people/peopleTypes';
|
|
|
346
346
|
import { fetchProfitAndLoss, fetchProfitAndLossForTimeframe, resetProfitAndLossNodeCollapseState, updateProfitAndLossUIState } from './view/profitAndLoss/profitAndLossReducer';
|
|
347
347
|
import { ProfitAndLossReport, getPandLReportFetchState, getProfitAndLossReport } from './view/profitAndLoss/profitAndLossSelector';
|
|
348
348
|
import { ProfitAndLossState, ProfitAndLossUIState } from './view/profitAndLoss/profitAndLossState';
|
|
349
|
-
import { fetchProfitAndLossClassesView, resetProfitAndLossClassesNodeCollapseState, updateAccountViewMode as updateProfitAndLossAccountViewMode, updateClassesToFilterOut as updateProfitAndLossClassesToFilterOut, updateProfitAndLossClassesViewUIState } from './view/profitAndLossClassesView/profitAndLossClassesViewReducer';
|
|
349
|
+
import { fetchProfitAndLossClassesView, resetProfitAndLossClassesNodeCollapseState, updateAccountViewMode as updateProfitAndLossAccountViewMode, updateClassesToFilterOut as updateProfitAndLossClassesToFilterOut, updateClassViewLayout, updateProfitAndLossClassesViewUIState } from './view/profitAndLossClassesView/profitAndLossClassesViewReducer';
|
|
350
|
+
import { getProfitAndLossClassesHorizontalView } from './view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector';
|
|
351
|
+
import { ClassColumnDefinition, HorizontalAccountRow, HorizontalCalculatedSection, HorizontalClassBalance, HorizontalSectionReport, ProfitAndLossByClassHorizontalReport } from './view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes';
|
|
350
352
|
import { getProfitAndLossClassesView } from './view/profitAndLossClassesView/profitAndLossClassesViewSelector';
|
|
351
353
|
import { PandLReportViewCalculatedSectionID, PandLReportViewSectionID, ProfitAndLossClassesViewReport, isPandLReportViewCalculatedSectionID, isPandLReportViewSectionID } from './view/profitAndLossClassesView/profitAndLossClassesViewSelectorTypes';
|
|
352
|
-
import { ProfitAndLossClassesViewUIState } from './view/profitAndLossClassesView/profitAndLossClassesViewState';
|
|
354
|
+
import { ClassViewLayout, ProfitAndLossClassesViewUIState } from './view/profitAndLossClassesView/profitAndLossClassesViewState';
|
|
353
355
|
import { fetchEntityRecommendationsByTransactionId, fetchRecommendationByEntityId, fetchRecommendationByEntityName } from './view/recommendation/recommendationReducer';
|
|
354
356
|
import { clearReferrals, fetchReferrals, fetchRewardsPlan, resendReferralInvite, saveReferralFormDataInLocalStore, sendReferralInvite, updateReferViewed, updateReferralListSortUiState } from './view/referralView/referralReducer';
|
|
355
357
|
import { ReferralListSelectorView, RewardsPlanCardReport, getInviteFormView, getReferralListView, getRewardsPlanCard } from './view/referralView/referralSelector';
|
|
@@ -664,7 +666,7 @@ export { fetchDashboard, getDashboard, DashboardReport, updateTreasuryVideoClose
|
|
|
664
666
|
export { updateDashboardLayout };
|
|
665
667
|
export { PandLWithForecastView, getPandLWithForecast, } from './view/profitAndLoss/pAndLWithForecast/pAndLWithForecastSelector';
|
|
666
668
|
export { fetchProfitAndLoss, resetProfitAndLossNodeCollapseState, updateProfitAndLossUIState, ProfitAndLossState, ProfitAndLossUIState, getProfitAndLossReport, ProfitAndLossReport, getPandLReportFetchState, fetchProfitAndLossForTimeframe, };
|
|
667
|
-
export { fetchProfitAndLossClassesView, updateProfitAndLossClassesToFilterOut, resetProfitAndLossClassesNodeCollapseState, updateProfitAndLossClassesViewUIState, updateProfitAndLossAccountViewMode, ProfitAndLossClassesViewUIState, ProfitAndLossClassesViewReport, getProfitAndLossClassesView, PandLReportViewSectionID, PandLReportViewCalculatedSectionID, isPandLReportViewCalculatedSectionID, isPandLReportViewSectionID, };
|
|
669
|
+
export { fetchProfitAndLossClassesView, updateProfitAndLossClassesToFilterOut, resetProfitAndLossClassesNodeCollapseState, updateProfitAndLossClassesViewUIState, updateProfitAndLossAccountViewMode, updateClassViewLayout, ProfitAndLossClassesViewUIState, ProfitAndLossClassesViewReport, getProfitAndLossClassesView, getProfitAndLossClassesHorizontalView, PandLReportViewSectionID, PandLReportViewCalculatedSectionID, isPandLReportViewCalculatedSectionID, isPandLReportViewSectionID, ClassViewLayout, ProfitAndLossByClassHorizontalReport, ClassColumnDefinition, HorizontalAccountRow, HorizontalClassBalance, HorizontalSectionReport, HorizontalCalculatedSection, };
|
|
668
670
|
export { AccountingProviderAttachmentSelector, getAccountingProviderAttachment };
|
|
669
671
|
export { fetchUserListByType, getUserList, UserListSelectorView };
|
|
670
672
|
export { fetchAllPeopleRequiredViews, fetchPeoplePage, fetchPeople, deletePerson, resendInvite, changeZeniPersonRoles, invitePeople, inviteZeniPeople, updatePeopleUIState, peopleSaveUpdates, resetUpdateErrorMessage, peopleSaveDataInLocalStore, peopleClearDataInLocalStore, PeopleSelectorView, PeopleLocalDataView, Person, getPeople, getPeopleLocalData, PeopleState, PersonUpdateType, PeoplePageMode, ZeniPersonUserRoleType, PeopleUIState, PeopleLocalData, initializeEditPerson, };
|
|
@@ -828,7 +830,7 @@ export { fetchApAgingDetail, AgingReportInvoice, ApAgingDetail, getApAgingDetail
|
|
|
828
830
|
export { LinkBillExpenseKey };
|
|
829
831
|
export { clearExpenseAutomationJEScheduleLocalData, clearExpenseAutomationJESchedulesView, fetchExpenseAutomationJESchedulesPage, ignoreExpenseAutomationJESchedule, initializeJeAccountSettingsView, initializeJeScheduleLocalData, removeJeScheduleTransactionKey, retryExpenseAutomationJESchedule, updateJeScheduleLocalDataById, updateJeScheduleTransactionKeys, };
|
|
830
832
|
export { createNewSchedulesAccrued, deleteScheduleAccruedDetail, cancelScheduleAccruedJournalEntry, fetchScheduleAccruedDetails, fetchScheduleAccruedDetailsPage, resetJEAccruedLinkInLocalData, saveScheduleAccruedDetails, updateAmountsInScheduleAccruedDetail, updatedJEAccruedLinkWithRecommendedLocalData, updatedJELinkInLocalDataAccruedExpenses, fetchRecommendedTransactionRowIndex, clearSelectedJELinkRowIndex, updateLinkBillExpenseLocalData, updateScheduleAccruedDetailsLocalData, updateSelectedJEAccruedScheduleKey, resetSelectedJEAccruedScheduleKey, resetAccruedDetailNewScheduleState, };
|
|
831
|
-
export { JEScheduleKey, JEScheduleTransactionKey, ALL_SCHEDULES_TYPES, JEScheduledTransaction, JEAccruedSchedule, ScheduleTypes, ScheduleJournalEntryStatusCodeType, ScheduleListReport, ScheduleAccruedListReport, getScheduleListReport, getAccruedScheduleListReport, ScheduleSubTabType, ScheduleListSortKey, fetchScheduleList, fetchAccruedScheduleList, fetchDownloadSchedules, fetchSchedulesAccount, updateScheduleListLocalData, getFetchStateForScheduleAccountList, toScheduleTypesType, toScheduleTypesTypeStrict, toScheduleListTabsFileTypeStrict, ScheduleListLocalData, ScheduleDetailsLocalDataFixedAssets, ScheduleDetailsLocalDataAccruedExpenses, ScheduleDetailsView, ScheduleAccruedDetailsView, LinkBillExpenseView, LinkBillExpenseLocalData, JEScheduleDetailsLocalData, ScheduleDetailsLocalData, toScheduleSubTabType, ScheduleStatusCodeType, JournalEntryErrorCodeType, ScheduleTransaction, updateScheduleListSubTab, updateScheduleListSearchText, updateScheduleListScrollState, updateScheduleListSortState, ScheduleDetailSortKey, ScheduledJournalEntry, updateSelectedJEScheduleKey, fetchScheduleDetails, getScheduleDetailsView, getAccruedScheduleDetailsView, fetchScheduleDetailsPage, saveScheduleDetails, deleteScheduleDetail, createNewSchedules, updateScheduleDetailsLocalData, JETransactionLink, updateScheduleListDownloadState, updateAccruedJEScheduleAccruedByListKey, DownloadJEScheduleTabOptions, updatedSelectedJELinkRowIndex, ScheduleListTabsFileType, getQBOUrlForLink, getThirdPartyIDFromQBOURL, updatedJELinkInLocalData, updateAmountsInScheduleDetail, ScheduleDetailUIState, resetJELinkInLocalData, JEScheduledTransactionWithBalance, JEScheduleWithBalance, JELinkType, updatedJELinkWithRecommendedLocalData, getFetchStateForScheduleListByType, getDefaultSelectedTimeframeForScheduleType, markAsCompleteScheduleDetail, resetMarkAsCompleteStatus, fetchVendorTabView, updateVendorTabViewTab, VendorTabViewTabType, getVendorTabView, VendorTabViewSelectorView, };
|
|
833
|
+
export { JEScheduleKey, JEScheduleTransactionKey, ScheduleTransactionID, getJEScheduleTransactionKey, ALL_SCHEDULES_TYPES, JEScheduledTransaction, JEAccruedSchedule, ScheduleTypes, ScheduleJournalEntryStatusCodeType, ScheduleListReport, ScheduleAccruedListReport, getScheduleListReport, getAccruedScheduleListReport, ScheduleSubTabType, ScheduleListSortKey, fetchScheduleList, fetchAccruedScheduleList, fetchDownloadSchedules, fetchSchedulesAccount, updateScheduleListLocalData, getFetchStateForScheduleAccountList, toScheduleTypesType, toScheduleTypesTypeStrict, toScheduleListTabsFileTypeStrict, ScheduleListLocalData, ScheduleDetailsLocalDataFixedAssets, ScheduleDetailsLocalDataAccruedExpenses, ScheduleDetailsView, ScheduleAccruedDetailsView, LinkBillExpenseView, LinkBillExpenseLocalData, JEScheduleDetailsLocalData, ScheduleDetailsLocalData, toScheduleSubTabType, ScheduleStatusCodeType, JournalEntryErrorCodeType, ScheduleTransaction, updateScheduleListSubTab, updateScheduleListSearchText, updateScheduleListScrollState, updateScheduleListSortState, ScheduleDetailSortKey, ScheduledJournalEntry, updateSelectedJEScheduleKey, fetchScheduleDetails, getScheduleDetailsView, getAccruedScheduleDetailsView, fetchScheduleDetailsPage, saveScheduleDetails, deleteScheduleDetail, createNewSchedules, updateScheduleDetailsLocalData, JETransactionLink, updateScheduleListDownloadState, updateAccruedJEScheduleAccruedByListKey, DownloadJEScheduleTabOptions, updatedSelectedJELinkRowIndex, ScheduleListTabsFileType, getQBOUrlForLink, getThirdPartyIDFromQBOURL, updatedJELinkInLocalData, updateAmountsInScheduleDetail, ScheduleDetailUIState, resetJELinkInLocalData, JEScheduledTransactionWithBalance, JEScheduleWithBalance, JELinkType, updatedJELinkWithRecommendedLocalData, getFetchStateForScheduleListByType, getDefaultSelectedTimeframeForScheduleType, markAsCompleteScheduleDetail, resetMarkAsCompleteStatus, fetchVendorTabView, updateVendorTabViewTab, VendorTabViewTabType, getVendorTabView, VendorTabViewSelectorView, };
|
|
832
834
|
export { GlobalMerchant, GlobalMerchantBase, TenantMerchant };
|
|
833
835
|
export { ReviewStatus, VendorTransactionAttachment, VendorTransactionAttachmentPayload, VendorFirstReviewViewSelectorView, VendorFirstReviewViewLocalData, VendorFirstReviewSelectorView, VendorFirstReviewSelectorAttachmentView, VendorFirstReviewViewUIState, VendorFirstReviewViewColumnKey, GlobalMerchantAutoCompleteView, VendorReviewRowCurrentSelection, toVendorFirstReviewViewColumnKeyType, RecommendedNonExistingGlobalMerchant, getGlobalMerchantAutoCompleteResults, VendorReviewRecommendationViewState, GlobalMerchantType, getVendorFirstReviewView, getVendorFirstReviewAttachmentView, fetchVendorFirstReviewView, fetchVendorFirstReviewAttachments, updateVendorFirstReviewViewScrollYOffset, resetVendorFirstReviewLocalData, updateVendorFirstReviewViewPageToken, clearRecentlySavedErroredVendorData, saveVendorFirstReviewView, updateVendorFirstReviewViewLocalData, updateVendorFirstReviewSortUiState, fetchGlobalMerchantAutoCompleteView, clearGlobalMerchantAutoCompleteResults, GlobalVendorReviewRowCurrentSelection, FirstReviewPageCurrentSelectionByColumn, updateReviewVendorDetailLocalData, saveVendorDetailsView, getVendorDetailSelectorView, FirstReviewVendorDetailSelectorView, VendorViewLocalData, };
|
|
834
836
|
export { fetchGlobalMerchantRecommendation, createGlobalMerchant, updateCreateGlobalMerchantLocalData, clearGlobalMerchantView, getGlobalMerchantView, GlobalMerchantViewSelectorView, GlobalMerchantViewState, NewGlobalMerchantData, NewGlobalMerchantCurrentSelection, };
|