@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
|
@@ -22,23 +22,23 @@ export declare const clearExpenseAutomationJESchedulesView: import("@reduxjs/too
|
|
|
22
22
|
jeSchedules: JEScheduledTransactionPayload[];
|
|
23
23
|
refreshViewInBackground: boolean;
|
|
24
24
|
selectedPeriod: MonthYearPeriod;
|
|
25
|
-
}, "expenseAutomationJESchedulesView/fetchJeSchedulesSuccess">, fetchRecommendationForAccountSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/fetchRecommendationForAccountSettings">, ignoreRecommendedJeSchedule: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleTransactionKey: `${string}
|
|
26
|
-
jeScheduleTransactionKey: `${string}
|
|
25
|
+
}, "expenseAutomationJESchedulesView/fetchJeSchedulesSuccess">, fetchRecommendationForAccountSettings: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/fetchRecommendationForAccountSettings">, ignoreRecommendedJeSchedule: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleTransactionKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`, scheduleType: "prepaid_expenses" | "fixed_assets" | "accrued_expenses" | "deferred_revenue"], {
|
|
26
|
+
jeScheduleTransactionKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`;
|
|
27
27
|
scheduleType: "prepaid_expenses" | "fixed_assets" | "accrued_expenses" | "deferred_revenue";
|
|
28
28
|
}, "expenseAutomationJESchedulesView/ignoreRecommendedJeSchedule", never, never>, ignoreRecommendedJeScheduleFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
29
29
|
jeScheduleTransactionKey: JEScheduleTransactionKey;
|
|
30
30
|
status: ZeniAPIStatus;
|
|
31
|
-
}, "expenseAutomationJESchedulesView/ignoreRecommendedJeScheduleFailure">, ignoreRecommendedJeScheduleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleTransactionKey: `${string}
|
|
32
|
-
jeScheduleTransactionKey: `${string}
|
|
31
|
+
}, "expenseAutomationJESchedulesView/ignoreRecommendedJeScheduleFailure">, ignoreRecommendedJeScheduleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleTransactionKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`], {
|
|
32
|
+
jeScheduleTransactionKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`;
|
|
33
33
|
}, "expenseAutomationJESchedulesView/ignoreRecommendedJeScheduleSuccess", never, never>, initializeAccountSettingsView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"expenseAutomationJESchedulesView/initializeAccountSettingsView">, initializeJeScheduleLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeSchedules: JEScheduledTransactionPayload[]], {
|
|
34
|
-
jeScheduleTransactionKeys: (`${string}
|
|
35
|
-
}, "expenseAutomationJESchedulesView/initializeJeScheduleLocalData", never, never>, removeFailedJeScheduleTransactionKey: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[failedJeScheduleKey: `${string}
|
|
36
|
-
failedJeScheduleKey: `${string}
|
|
34
|
+
jeScheduleTransactionKeys: (`${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`)[];
|
|
35
|
+
}, "expenseAutomationJESchedulesView/initializeJeScheduleLocalData", never, never>, removeFailedJeScheduleTransactionKey: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[failedJeScheduleKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`, selectedPeriod: MonthYearPeriod], {
|
|
36
|
+
failedJeScheduleKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`;
|
|
37
37
|
selectedPeriod: MonthYearPeriod;
|
|
38
38
|
}, "expenseAutomationJESchedulesView/removeFailedJeScheduleTransactionKey", never, never>, removeJeScheduleLocalDataById: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
39
39
|
scheduledJournalEntryID: ID;
|
|
40
|
-
}, "expenseAutomationJESchedulesView/removeJeScheduleLocalDataById">, removeJeScheduleTransactionKey: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleKey: `${string}
|
|
41
|
-
jeScheduleKey: `${string}
|
|
40
|
+
}, "expenseAutomationJESchedulesView/removeJeScheduleLocalDataById">, removeJeScheduleTransactionKey: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`, selectedPeriod: MonthYearPeriod], {
|
|
41
|
+
jeScheduleKey: `${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`;
|
|
42
42
|
selectedPeriod: MonthYearPeriod;
|
|
43
43
|
}, "expenseAutomationJESchedulesView/removeJeScheduleTransactionKey", never, never>, retryJeSchedule: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
44
44
|
jeScheduleTransactionKey: JEScheduleTransactionKey;
|
|
@@ -59,8 +59,8 @@ export declare const clearExpenseAutomationJESchedulesView: import("@reduxjs/too
|
|
|
59
59
|
}, "expenseAutomationJESchedulesView/updateAccountSettingsListForAccountTypesFailure">, updateJeScheduleLocalDataById: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
60
60
|
localData: Partial<JEScheduleLocalData>;
|
|
61
61
|
scheduledJournalEntryID: ID;
|
|
62
|
-
}, "expenseAutomationJESchedulesView/updateJeScheduleLocalDataById">, updateJeScheduleTransactionKeys: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleKeys: (`${string}
|
|
63
|
-
jeScheduleKeys: (`${string}
|
|
62
|
+
}, "expenseAutomationJESchedulesView/updateJeScheduleLocalDataById">, updateJeScheduleTransactionKeys: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleKeys: (`${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`)[], selectedPeriod: MonthYearPeriod], {
|
|
63
|
+
jeScheduleKeys: (`${string}_bill_${string}` | `${string}_expense_${string}` | `${string}_check_${string}` | `${string}_refund_${string}` | `${string}_invoice_${string}` | `${string}_payment_${string}` | `${string}_credit_memo_${string}` | `${string}_sales_receipt_${string}` | `${string}_delayed_credit_${string}` | `${string}_delayed_charge_${string}` | `${string}_bill_payment_${string}` | `${string}_bill_payment_check_${string}` | `${string}_bill_payment_credit_card_${string}` | `${string}_vendor_credit_${string}` | `${string}_credit_card_credit_${string}` | `${string}_transfer_${string}` | `${string}_credit_card_payment_${string}` | `${string}_deposit_${string}` | `${string}_journal_entry_${string}`)[];
|
|
64
64
|
selectedPeriod: MonthYearPeriod;
|
|
65
65
|
}, "expenseAutomationJESchedulesView/updateJeScheduleTransactionKeys", never, never>, updateRecommendationForAccountSettings: import("@reduxjs/toolkit").ActionCreatorWithPayload<AccountTypeRecommendationPayload, "expenseAutomationJESchedulesView/updateRecommendationForAccountSettings">, updateRecommendationForAccountSettingsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
66
66
|
status: ZeniAPIStatus;
|
|
@@ -7,9 +7,7 @@ const getNestedAccountIDHierarchyForReport_1 = require("../../../commonStateType
|
|
|
7
7
|
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
8
8
|
const accountPayload_1 = require("../../../entity/account/accountPayload");
|
|
9
9
|
const jeSchedulesPayload_1 = require("../../../entity/jeSchedules/jeSchedulesPayload");
|
|
10
|
-
const transactionIDPayload_1 = require("../../../entity/transaction/payloadTypes/transactionIDPayload");
|
|
11
10
|
const accountTypeRecommendationPayload_1 = require("../../accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload");
|
|
12
|
-
const transactionDetailState_1 = require("../../transactionDetail/transactionDetailState");
|
|
13
11
|
exports.accountSettingsInitialState = {
|
|
14
12
|
localData: {
|
|
15
13
|
selectedPrepaidExpensesAccountIds: [],
|
|
@@ -103,14 +101,8 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
|
|
|
103
101
|
},
|
|
104
102
|
fetchJeSchedulesSuccess(draft, action) {
|
|
105
103
|
const { jeSchedules, selectedPeriod, failedJeSchedules, refreshViewInBackground, } = action.payload;
|
|
106
|
-
const jeScheduleTransactionKeys = jeSchedules.map((schedules) =>
|
|
107
|
-
|
|
108
|
-
return (0, transactionDetailState_1.getZeniTransactionDetailKey)(transactionID);
|
|
109
|
-
});
|
|
110
|
-
const failedJeScheduleTransactionKeys = failedJeSchedules.map((schedules) => {
|
|
111
|
-
const transactionID = (0, transactionIDPayload_1.toTransactionID)(schedules.base_transaction);
|
|
112
|
-
return (0, transactionDetailState_1.getZeniTransactionDetailKey)(transactionID);
|
|
113
|
-
});
|
|
104
|
+
const jeScheduleTransactionKeys = jeSchedules.map((schedules) => (0, jeSchedulesPayload_1.getJEScheduleTransactionDetailKeyPayload)(schedules.base_transaction));
|
|
105
|
+
const failedJeScheduleTransactionKeys = failedJeSchedules.map((schedules) => (0, jeSchedulesPayload_1.getJEScheduleTransactionDetailKeyPayload)(schedules.base_transaction));
|
|
114
106
|
if (refreshViewInBackground === true &&
|
|
115
107
|
draft.refreshStatus.fetchState === 'In-Progress') {
|
|
116
108
|
draft.refreshStatus = { fetchState: 'Completed', error: undefined };
|
|
@@ -276,7 +268,7 @@ const expenseAutomationJESchedulesView = (0, toolkit_1.createSlice)({
|
|
|
276
268
|
return {
|
|
277
269
|
payload: {
|
|
278
270
|
jeScheduleTransactionKeys: [
|
|
279
|
-
...jeSchedules.map((jeSchedule) => (0, jeSchedulesPayload_1.
|
|
271
|
+
...jeSchedules.map((jeSchedule) => (0, jeSchedulesPayload_1.getJEScheduleTransactionDetailKeyPayload)(jeSchedule.base_transaction)),
|
|
280
272
|
],
|
|
281
273
|
},
|
|
282
274
|
};
|
|
@@ -48,19 +48,20 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
48
48
|
updateFinanceStatementThisPeriod(draft, action) {
|
|
49
49
|
const { firstMonthOfFY, coaBalances, maxNumOfPeriodsToHighlight } = action.payload;
|
|
50
50
|
const { timeframe, selectedCOABalancesRange } = draft;
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const safeCoaBalances = coaBalances ?? [];
|
|
52
|
+
if (safeCoaBalances.length > 0) {
|
|
53
|
+
const prevThisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
|
|
53
54
|
if (prevThisPeriod != null) {
|
|
54
55
|
const selectedCoaBalancesRangeWithThisPeriod = {
|
|
55
56
|
...selectedCOABalancesRange,
|
|
56
57
|
thisPeriod: prevThisPeriod,
|
|
57
58
|
};
|
|
58
|
-
const newThisPeriod = (0, thisPeriodHelpers_1.getMatchingThisPeriod)(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod,
|
|
59
|
+
const newThisPeriod = (0, thisPeriodHelpers_1.getMatchingThisPeriod)(action.payload.firstMonthOfFY, timeframe, action.payload.thisPeriod, safeCoaBalances);
|
|
59
60
|
if (newThisPeriod != null) {
|
|
60
61
|
const selectionRanges = (0, getSelectedAndHighlightedRanges_1.getSelectedAndHighlightedRangesForThisPeriod)({
|
|
61
62
|
firstMonthOfFY,
|
|
62
63
|
thisPeriod: newThisPeriod,
|
|
63
|
-
coaBalances,
|
|
64
|
+
coaBalances: safeCoaBalances,
|
|
64
65
|
timeframe,
|
|
65
66
|
maxNumOfPeriodsToSelect: maxNumOfPeriodsToHighlight,
|
|
66
67
|
currentSelection: {
|
|
@@ -79,7 +80,9 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
79
80
|
draft.selectedReportId = action.payload;
|
|
80
81
|
},
|
|
81
82
|
updateFinanceStatementAdditionalBalancesSelection(draft, action) {
|
|
82
|
-
const { firstMonthOfFY, additionalBalances, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
|
|
83
|
+
const { firstMonthOfFY, additionalBalances: additionalBalancesPayload, coaBalances, maxNumOfPeriodsToHighlight, } = action.payload;
|
|
84
|
+
const safeCoaBalances = coaBalances ?? [];
|
|
85
|
+
const additionalBalances = additionalBalancesPayload ?? [];
|
|
83
86
|
let tempAdditionalBalances = [...additionalBalances];
|
|
84
87
|
if (additionalBalances.includes('this_period_vs_last_period') ||
|
|
85
88
|
additionalBalances.includes('this_period_vs_last_period_percent')) {
|
|
@@ -95,8 +98,8 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
95
98
|
draft.isAdditionalBalancesShown =
|
|
96
99
|
additionalBalances.length != 0 ? true : false;
|
|
97
100
|
const { timeframe, selectedCOABalancesRange } = draft;
|
|
98
|
-
if (
|
|
99
|
-
const thisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange,
|
|
101
|
+
if (safeCoaBalances.length > 0) {
|
|
102
|
+
const thisPeriod = (0, thisPeriodHelpers_1.extractThisPeriod)(action.payload.firstMonthOfFY, timeframe, selectedCOABalancesRange, safeCoaBalances);
|
|
100
103
|
if (thisPeriod != null) {
|
|
101
104
|
const selectedCoaBalancesRangeWithThisPeriod = {
|
|
102
105
|
...selectedCOABalancesRange,
|
|
@@ -105,7 +108,7 @@ const financeStatement = (0, toolkit_1.createSlice)({
|
|
|
105
108
|
const selectionRanges = (0, getSelectedAndHighlightedRanges_1.getSelectedAndHighlightedRangesForThisPeriod)({
|
|
106
109
|
firstMonthOfFY,
|
|
107
110
|
thisPeriod: thisPeriod,
|
|
108
|
-
coaBalances,
|
|
111
|
+
coaBalances: safeCoaBalances,
|
|
109
112
|
timeframe,
|
|
110
113
|
maxNumOfPeriodsToHighlight: maxNumOfPeriodsToHighlight,
|
|
111
114
|
currentSelection: {
|
|
@@ -8,6 +8,7 @@ import { RootState } from '../../reducer';
|
|
|
8
8
|
import { BalanceSheetReport } from '../balanceSheet/balanceSheetSelectorTypes';
|
|
9
9
|
import { CashFlowReport } from '../cashFlow/cashFlowSelectorTypes';
|
|
10
10
|
import { ProfitAndLossReport } from '../profitAndLoss/profitAndLossSelector';
|
|
11
|
+
import { ProfitAndLossByClassHorizontalReport } from '../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes';
|
|
11
12
|
import { ProfitAndLossClassesViewReport } from '../profitAndLossClassesView/profitAndLossClassesViewSelectorTypes';
|
|
12
13
|
export interface FinanceStatementReport extends SelectorReport {
|
|
13
14
|
allTimeframeTicks: TimeframeTickWithMetaData[];
|
|
@@ -18,6 +19,7 @@ export interface FinanceStatementReport extends SelectorReport {
|
|
|
18
19
|
downloadState: FetchState;
|
|
19
20
|
filter: COABalancesFilter;
|
|
20
21
|
isCompareModeOn: boolean;
|
|
22
|
+
profitAndLossByClassHorizontalReport: ProfitAndLossByClassHorizontalReport;
|
|
21
23
|
profitAndLossByClassReport: ProfitAndLossClassesViewReport;
|
|
22
24
|
profitAndLossReport: ProfitAndLossReport;
|
|
23
25
|
reportFormat: ReportFormat;
|
|
@@ -11,6 +11,7 @@ const thisPeriodHelpers_1 = require("../../commonStateTypes/viewAndReport/thisPe
|
|
|
11
11
|
const balanceSheetSelector_1 = require("../balanceSheet/balanceSheetSelector");
|
|
12
12
|
const cashFlowSelector_1 = require("../cashFlow/cashFlowSelector");
|
|
13
13
|
const profitAndLossSelector_1 = require("../profitAndLoss/profitAndLossSelector");
|
|
14
|
+
const profitAndLossClassesByClassHorizontalSelector_1 = require("../profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelector");
|
|
14
15
|
const profitAndLossClassesViewSelector_1 = require("../profitAndLossClassesView/profitAndLossClassesViewSelector");
|
|
15
16
|
function getDateRangeForFinanceReports(profitAndLossState, balanceSheetState, cashFlowState) {
|
|
16
17
|
const datesSorted = [
|
|
@@ -45,11 +46,15 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
45
46
|
if (dataAvailable != null) {
|
|
46
47
|
const noFilter = (0, coaBalancesFilter_1.newBalancesFilterForDateRange)(firstMonthOfFY, financeStatementState.timeframe, dataAvailable, 'ascending_date', []);
|
|
47
48
|
const profitAndLossForTimeframeTicks = (0, profitAndLossSelector_1.getProfitAndLossReport)(noFilter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
|
|
48
|
-
|
|
49
|
+
const expensesSection = profitAndLossForTimeframeTicks.sections.expenses;
|
|
50
|
+
const incomeSection = profitAndLossForTimeframeTicks.sections.income;
|
|
51
|
+
const expensesBalances = expensesSection?.balances;
|
|
52
|
+
const incomeBalances = incomeSection?.balances;
|
|
53
|
+
if (expensesSection != null) {
|
|
49
54
|
balancesInTimeframe =
|
|
50
|
-
|
|
51
|
-
?
|
|
52
|
-
:
|
|
55
|
+
(expensesBalances?.length ?? 0) > 0
|
|
56
|
+
? expensesBalances ?? []
|
|
57
|
+
: incomeBalances ?? [];
|
|
53
58
|
allTimeframeTicks = balancesInTimeframe.map((balance) => (0, timeframeTick_1.toTimeframeTick)(balance));
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -63,6 +68,9 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
63
68
|
const profitAndLossReport = (0, profitAndLossSelector_1.getProfitAndLossReport)(filter, undefined, accountState, accountGroupState, sectionAccountsViewState, profitAndLossState, forecastState);
|
|
64
69
|
const classFilter = (0, coaBalancesFilterClassesView_1.newBalancesFilterClassesView)(filter.firstMonthOfFY, filter.timeframe, filter.balancesRange.numberOfPeriods, filter.balancesRange.thisPeriod, filter.balancesRange.orderBy, filter.additionalBalances, profitAndLossClassesViewState.uiState.classesToFilterOut);
|
|
65
70
|
const profitAndLossByClassReport = (0, profitAndLossClassesViewSelector_1.getProfitAndLossClassesView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState);
|
|
71
|
+
const profitAndLossByClassHorizontalReport = profitAndLossClassesViewState.uiState.classViewLayout === 'horizontal'
|
|
72
|
+
? (0, profitAndLossClassesByClassHorizontalSelector_1.getProfitAndLossClassesHorizontalView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState, thisPeriod)
|
|
73
|
+
: (0, profitAndLossClassesByClassHorizontalSelector_1.getProfitAndLossClassesHorizontalView)(classFilter, accountState, classState, sectionsState, profitAndLossClassesViewState, undefined);
|
|
66
74
|
const balanceSheetReport = (0, balanceSheetSelector_1.getBalanceSheet)(filter, accountState, accountGroupState, sectionAccountsViewState, balanceSheetState);
|
|
67
75
|
const cashFlowReport = (0, cashFlowSelector_1.getCashFlow)(filter, accountState, accountGroupState, sectionAccountsViewState, cashFlowState);
|
|
68
76
|
const allReports = [
|
|
@@ -110,6 +118,7 @@ exports.getFinanceStatement = (0, toolkit_1.createSelector)((state) => state.acc
|
|
|
110
118
|
dataAvailable,
|
|
111
119
|
profitAndLossReport,
|
|
112
120
|
profitAndLossByClassReport,
|
|
121
|
+
profitAndLossByClassHorizontalReport,
|
|
113
122
|
balanceSheetReport,
|
|
114
123
|
cashFlowReport,
|
|
115
124
|
filter,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { COABalancesFilterClassesView } from '../../commonStateTypes/coaBalance/coaBalancesFilterClassesView';
|
|
2
|
+
import { AccountState } from '../../entity/account/accountState';
|
|
3
|
+
import { ClassState } from '../../entity/class/classState';
|
|
4
|
+
import { SectionClassesViewStateV2 } from '../../entity/sectionClassesViewV2/sectionClassesViewState';
|
|
5
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
6
|
+
import { ProfitAndLossByClassHorizontalReport } from './profitAndLossClassesByClassHorizontalSelectorTypes';
|
|
7
|
+
import { PandLReportViewCalculatedSectionID, PandLReportViewSectionID } from './profitAndLossClassesViewSelectorTypes';
|
|
8
|
+
import { ProfitAndLossClassesViewState } from './profitAndLossClassesViewState';
|
|
9
|
+
export declare const profitAndLossHorizontalIdsInOrder: (PandLReportViewSectionID | PandLReportViewCalculatedSectionID)[];
|
|
10
|
+
export declare const getProfitAndLossClassesHorizontalView: (filter: COABalancesFilterClassesView, accountState: AccountState, classState: ClassState, sectionsState: SectionClassesViewStateV2, profitAndLossClassesViewState: ProfitAndLossClassesViewState, selectedPeriod: {
|
|
11
|
+
endDate: ZeniDate;
|
|
12
|
+
startDate: ZeniDate;
|
|
13
|
+
} | undefined) => ProfitAndLossByClassHorizontalReport;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProfitAndLossClassesHorizontalView = exports.profitAndLossHorizontalIdsInOrder = void 0;
|
|
4
|
+
const amount_1 = require("../../commonStateTypes/amount");
|
|
5
|
+
const sectionClassesViewSelector_1 = require("../../entity/sectionClassesViewV2/sectionClassesViewSelector");
|
|
6
|
+
const profitAndLossClassesViewSelectorTypes_1 = require("./profitAndLossClassesViewSelectorTypes");
|
|
7
|
+
const DEFAULT_CURRENCY = { currencyCode: 'USD', currencySymbol: '$' };
|
|
8
|
+
exports.profitAndLossHorizontalIdsInOrder = [
|
|
9
|
+
'income',
|
|
10
|
+
'cogs',
|
|
11
|
+
'grossProfit',
|
|
12
|
+
'expenses',
|
|
13
|
+
'earningsBeforeInterestAndTax',
|
|
14
|
+
'otherIncome',
|
|
15
|
+
'otherExpenses',
|
|
16
|
+
'netOtherIncome',
|
|
17
|
+
'netIncome',
|
|
18
|
+
];
|
|
19
|
+
const SECTION_TITLES = {
|
|
20
|
+
income: 'Income',
|
|
21
|
+
cogs: 'Cost of Goods Sold',
|
|
22
|
+
grossProfit: 'Gross Profit',
|
|
23
|
+
expenses: 'Expenses',
|
|
24
|
+
earningsBeforeInterestAndTax: 'Net Operating Income',
|
|
25
|
+
otherIncome: 'Other Income',
|
|
26
|
+
otherExpenses: 'Other Expenses',
|
|
27
|
+
netOtherIncome: 'Net Other Income',
|
|
28
|
+
netIncome: 'Net Income',
|
|
29
|
+
};
|
|
30
|
+
const getProfitAndLossClassesHorizontalView = (filter, accountState, classState, sectionsState, profitAndLossClassesViewState, selectedPeriod) => {
|
|
31
|
+
const fetchState = reduceFetchState([
|
|
32
|
+
profitAndLossClassesViewState.fetchState.month,
|
|
33
|
+
profitAndLossClassesViewState.fetchState.quarter,
|
|
34
|
+
profitAndLossClassesViewState.fetchState.year,
|
|
35
|
+
]);
|
|
36
|
+
const reportId = 'profit_and_loss_by_classes';
|
|
37
|
+
// Build class columns from the class hierarchy (top-level only)
|
|
38
|
+
const classColumns = buildClassColumns(profitAndLossClassesViewState.classHierarchy, profitAndLossClassesViewState.uiState.classesToFilterOut);
|
|
39
|
+
const sections = {};
|
|
40
|
+
const calculatedSections = {};
|
|
41
|
+
if (fetchState.fetchState === 'Completed' && selectedPeriod != null) {
|
|
42
|
+
// Get section reports using existing selector infrastructure
|
|
43
|
+
const sectionReports = {};
|
|
44
|
+
profitAndLossClassesViewSelectorTypes_1.ALL_PANDL_REPORT_VIEW_SECTION_IDS.forEach((sectionId) => {
|
|
45
|
+
sectionReports[sectionId] = (0, sectionClassesViewSelector_1.getSectionClassesViewReport)(accountState, classState, sectionsState, { reportId, sectionId }, filter);
|
|
46
|
+
});
|
|
47
|
+
// Pivot each section from class→account to account→class
|
|
48
|
+
const sectionIds = [
|
|
49
|
+
'income',
|
|
50
|
+
'cogs',
|
|
51
|
+
'expenses',
|
|
52
|
+
'otherIncome',
|
|
53
|
+
'otherExpenses',
|
|
54
|
+
];
|
|
55
|
+
sectionIds.forEach((sectionId) => {
|
|
56
|
+
const sectionReport = sectionReports[sectionId];
|
|
57
|
+
if (sectionReport != null) {
|
|
58
|
+
sections[sectionId] = pivotSectionToHorizontal(sectionReport, classColumns, SECTION_TITLES[sectionId] ?? sectionId);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Calculate derived sections
|
|
62
|
+
const incomeSection = sections['income'];
|
|
63
|
+
const cogsSection = sections['cogs'];
|
|
64
|
+
const expensesSection = sections['expenses'];
|
|
65
|
+
const otherIncomeSection = sections['otherIncome'];
|
|
66
|
+
const otherExpensesSection = sections['otherExpenses'];
|
|
67
|
+
// Gross Profit = Income - COGS
|
|
68
|
+
if (incomeSection != null && cogsSection != null) {
|
|
69
|
+
calculatedSections['grossProfit'] = computeCalculatedSection(incomeSection.classTotals, cogsSection.classTotals, incomeSection.sectionTotal, cogsSection.sectionTotal, 'subtract', SECTION_TITLES['grossProfit']);
|
|
70
|
+
}
|
|
71
|
+
// EBIT = Gross Profit - Expenses
|
|
72
|
+
const grossProfit = calculatedSections['grossProfit'];
|
|
73
|
+
if (grossProfit != null && expensesSection != null) {
|
|
74
|
+
calculatedSections['earningsBeforeInterestAndTax'] =
|
|
75
|
+
computeCalculatedSection(grossProfit.classTotals, expensesSection.classTotals, grossProfit.sectionTotal, expensesSection.sectionTotal, 'subtract', SECTION_TITLES['earningsBeforeInterestAndTax']);
|
|
76
|
+
}
|
|
77
|
+
// Net Other Income = Other Income - Other Expenses
|
|
78
|
+
if (otherIncomeSection != null && otherExpensesSection != null) {
|
|
79
|
+
calculatedSections['netOtherIncome'] = computeCalculatedSection(otherIncomeSection.classTotals, otherExpensesSection.classTotals, otherIncomeSection.sectionTotal, otherExpensesSection.sectionTotal, 'subtract', SECTION_TITLES['netOtherIncome']);
|
|
80
|
+
}
|
|
81
|
+
// Net Income = EBIT + Net Other Income
|
|
82
|
+
const ebit = calculatedSections['earningsBeforeInterestAndTax'];
|
|
83
|
+
const netOtherIncome = calculatedSections['netOtherIncome'];
|
|
84
|
+
if (ebit != null && netOtherIncome != null) {
|
|
85
|
+
calculatedSections['netIncome'] = computeCalculatedSection(ebit.classTotals, netOtherIncome.classTotals, ebit.sectionTotal, netOtherIncome.sectionTotal, 'add', SECTION_TITLES['netIncome']);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Build synthetic header COABalances for rendering class names as column headers
|
|
89
|
+
const headerBalances = buildHeaderBalances(classColumns, filter.timeframe, selectedPeriod);
|
|
90
|
+
return {
|
|
91
|
+
reportId,
|
|
92
|
+
reportTitle: 'Profit and Loss by Class',
|
|
93
|
+
firstMonthOfFY: profitAndLossClassesViewState.firstMonthOfFY,
|
|
94
|
+
fetchState: fetchState.fetchState,
|
|
95
|
+
bookCloseDate: profitAndLossClassesViewState.bookCloseDate,
|
|
96
|
+
dataAvailable: profitAndLossClassesViewState.dataAvailable,
|
|
97
|
+
selectedPeriod,
|
|
98
|
+
classColumns,
|
|
99
|
+
sections,
|
|
100
|
+
calculatedSections,
|
|
101
|
+
idsInOrder: exports.profitAndLossHorizontalIdsInOrder,
|
|
102
|
+
uiState: profitAndLossClassesViewState.uiState,
|
|
103
|
+
headerBalances,
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
exports.getProfitAndLossClassesHorizontalView = getProfitAndLossClassesHorizontalView;
|
|
107
|
+
/**
|
|
108
|
+
* Build column definitions from class hierarchy (top-level classes only).
|
|
109
|
+
*/
|
|
110
|
+
function buildClassColumns(classHierarchy, classesToFilterOut) {
|
|
111
|
+
return classHierarchy
|
|
112
|
+
.filter((c) => !classesToFilterOut.some((filteredId) => filteredId[0] === c.classId[0]))
|
|
113
|
+
.map((c) => ({
|
|
114
|
+
classId: c.classId[0],
|
|
115
|
+
className: c.className,
|
|
116
|
+
nestedClassId: c.classId,
|
|
117
|
+
qboId: c.qboId,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Pivot a section from class→account→balances to account→class→balance (single period).
|
|
122
|
+
*/
|
|
123
|
+
function pivotSectionToHorizontal(section, classColumns, title) {
|
|
124
|
+
// Map: accountId -> { accountName, classId -> balance }
|
|
125
|
+
const accountMap = new Map();
|
|
126
|
+
// Also track class totals
|
|
127
|
+
const classTotalMap = new Map();
|
|
128
|
+
classColumns.forEach((col) => classTotalMap.set(col.classId, 0));
|
|
129
|
+
// Iterate over each class in the section
|
|
130
|
+
section.classes.forEach((classReport) => {
|
|
131
|
+
const classId = classReport.id[0];
|
|
132
|
+
// Only process classes that are in our columns
|
|
133
|
+
if (!classColumns.some((col) => col.classId === classId)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
// Sum all sliced period balances (same slice as vertical columns; multi-period = range total)
|
|
137
|
+
const classBalance = sumBalancesInSlice(classReport.childrenBalancesTotal.balances);
|
|
138
|
+
classTotalMap.set(classId, classBalance);
|
|
139
|
+
// Iterate through accounts in this class
|
|
140
|
+
collectAccountsFromClass(classReport, classId, accountMap);
|
|
141
|
+
});
|
|
142
|
+
// Build account rows
|
|
143
|
+
const accounts = [];
|
|
144
|
+
accountMap.forEach((accountData, accountId) => {
|
|
145
|
+
const classBalances = classColumns.map((col) => ({
|
|
146
|
+
classId: col.classId,
|
|
147
|
+
balance: (0, amount_1.toAmountWC)(accountData.classBalances.get(col.classId) ?? 0, DEFAULT_CURRENCY),
|
|
148
|
+
}));
|
|
149
|
+
const rowTotal = classBalances.reduce((sum, cb) => sum + cb.balance.amount, 0);
|
|
150
|
+
accounts.push({
|
|
151
|
+
accountId,
|
|
152
|
+
accountName: accountData.accountName,
|
|
153
|
+
classBalances,
|
|
154
|
+
rowTotal: (0, amount_1.toAmountWC)(rowTotal, DEFAULT_CURRENCY),
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
// Build class totals
|
|
158
|
+
const classTotals = classColumns.map((col) => ({
|
|
159
|
+
classId: col.classId,
|
|
160
|
+
balance: (0, amount_1.toAmountWC)(classTotalMap.get(col.classId) ?? 0, DEFAULT_CURRENCY),
|
|
161
|
+
}));
|
|
162
|
+
const sectionTotal = classTotals.reduce((sum, ct) => sum + ct.balance.amount, 0);
|
|
163
|
+
return {
|
|
164
|
+
title,
|
|
165
|
+
accounts,
|
|
166
|
+
classTotals,
|
|
167
|
+
sectionTotal: (0, amount_1.toAmountWC)(sectionTotal, DEFAULT_CURRENCY),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Recursively collect account balances from a NestedClassReportV2 into accountMap.
|
|
172
|
+
*/
|
|
173
|
+
function collectAccountsFromClass(classReport, classId, accountMap) {
|
|
174
|
+
// Process accounts directly on this class
|
|
175
|
+
classReport.class.accounts.forEach((nestedAccount) => {
|
|
176
|
+
collectAccountsFromNestedAccount(nestedAccount, classId, accountMap);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Recursively collect accounts from NestedAccountReport (handles sub-accounts).
|
|
181
|
+
*/
|
|
182
|
+
function collectAccountsFromNestedAccount(nestedAccount, classId, accountMap) {
|
|
183
|
+
const accountId = nestedAccount.account.accountId;
|
|
184
|
+
const accountName = nestedAccount.account.accountName;
|
|
185
|
+
const balance = sumBalancesInSlice(nestedAccount.account.balancesInTimeframe.balances);
|
|
186
|
+
if (!accountMap.has(accountId)) {
|
|
187
|
+
accountMap.set(accountId, {
|
|
188
|
+
accountName,
|
|
189
|
+
classBalances: new Map(),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const accountData = accountMap.get(accountId);
|
|
193
|
+
if (accountData == null) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const existing = accountData.classBalances.get(classId) ?? 0;
|
|
197
|
+
accountData.classBalances.set(classId, existing + balance);
|
|
198
|
+
// Process sub-accounts
|
|
199
|
+
nestedAccount.children.forEach((child) => {
|
|
200
|
+
collectAccountsFromNestedAccount(child, classId, accountMap);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Total amount for the current report slice. `balances` is already narrowed by
|
|
205
|
+
* `getCOABalances` / `sliceCOABalances` to the selected range; summing matches
|
|
206
|
+
* multi-period selections and avoids mismatches when `thisPeriod` does not
|
|
207
|
+
* align with a row (e.g. slice fallback) or when several period rows are shown.
|
|
208
|
+
*/
|
|
209
|
+
function sumBalancesInSlice(balances) {
|
|
210
|
+
let sum = 0;
|
|
211
|
+
for (const bal of balances) {
|
|
212
|
+
const b = bal;
|
|
213
|
+
sum += b.balance?.amount ?? 0;
|
|
214
|
+
}
|
|
215
|
+
return sum;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Compute a calculated section by adding or subtracting two sets of class totals.
|
|
219
|
+
*/
|
|
220
|
+
function computeCalculatedSection(aTotals, bTotals, aTotal, bTotal, operation, title) {
|
|
221
|
+
const classTotals = aTotals.map((a) => {
|
|
222
|
+
const bMatch = bTotals.find((b) => b.classId === a.classId);
|
|
223
|
+
const bAmount = bMatch?.balance.amount ?? 0;
|
|
224
|
+
const resultAmount = operation === 'add'
|
|
225
|
+
? a.balance.amount + bAmount
|
|
226
|
+
: a.balance.amount - bAmount;
|
|
227
|
+
return {
|
|
228
|
+
classId: a.classId,
|
|
229
|
+
balance: (0, amount_1.toAmountWC)(resultAmount, DEFAULT_CURRENCY),
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
const sectionTotalAmount = operation === 'add'
|
|
233
|
+
? aTotal.amount + bTotal.amount
|
|
234
|
+
: aTotal.amount - bTotal.amount;
|
|
235
|
+
return {
|
|
236
|
+
title,
|
|
237
|
+
classTotals,
|
|
238
|
+
sectionTotal: (0, amount_1.toAmountWC)(sectionTotalAmount, DEFAULT_CURRENCY),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Build synthetic COABalance array for header rendering.
|
|
243
|
+
* One entry per class column + one for "Total".
|
|
244
|
+
*/
|
|
245
|
+
function buildHeaderBalances(classColumns, timeframe, selectedPeriod) {
|
|
246
|
+
if (selectedPeriod == null) {
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
const { endDate, startDate } = selectedPeriod;
|
|
250
|
+
const balances = classColumns.map((col) => ({
|
|
251
|
+
balance: (0, amount_1.toAmountWC)(0, DEFAULT_CURRENCY),
|
|
252
|
+
balanceTimeFrame: timeframe,
|
|
253
|
+
endDate,
|
|
254
|
+
startDate,
|
|
255
|
+
type: 'default',
|
|
256
|
+
label: col.className,
|
|
257
|
+
}));
|
|
258
|
+
// Add a "Total" column
|
|
259
|
+
balances.push({
|
|
260
|
+
balance: (0, amount_1.toAmountWC)(0, DEFAULT_CURRENCY),
|
|
261
|
+
balanceTimeFrame: timeframe,
|
|
262
|
+
endDate,
|
|
263
|
+
startDate,
|
|
264
|
+
type: 'default',
|
|
265
|
+
label: 'Total',
|
|
266
|
+
});
|
|
267
|
+
return balances;
|
|
268
|
+
}
|
|
269
|
+
function reduceFetchState(fetchStateList) {
|
|
270
|
+
const isAnyProgress = fetchStateList.some((s) => s.fetchState === 'In-Progress');
|
|
271
|
+
const isAllCompleted = fetchStateList.every((s) => s.fetchState === 'Completed');
|
|
272
|
+
const isAnyError = fetchStateList.some((s) => s.fetchState === 'Error');
|
|
273
|
+
const error = fetchStateList.find((s) => s.error != null)?.error;
|
|
274
|
+
let fetchState = 'Not-Started';
|
|
275
|
+
if (isAnyProgress) {
|
|
276
|
+
fetchState = 'In-Progress';
|
|
277
|
+
}
|
|
278
|
+
else if (isAllCompleted) {
|
|
279
|
+
fetchState = 'Completed';
|
|
280
|
+
}
|
|
281
|
+
else if (isAnyError) {
|
|
282
|
+
fetchState = 'Error';
|
|
283
|
+
}
|
|
284
|
+
return { fetchState, error };
|
|
285
|
+
}
|
package/lib/view/profitAndLossClassesView/profitAndLossClassesByClassHorizontalSelectorTypes.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Amount } from '../../commonStateTypes/amount';
|
|
2
|
+
import { NestedClassID } from '../../commonStateTypes/classesView/nestedClassID';
|
|
3
|
+
import { COABalance } from '../../commonStateTypes/coaBalance/coaBalance';
|
|
4
|
+
import { FetchState, ID } from '../../commonStateTypes/common';
|
|
5
|
+
import { DataAvailable } from '../../commonStateTypes/dataAvailable';
|
|
6
|
+
import { Month } from '../../commonStateTypes/timePeriod';
|
|
7
|
+
import { ReportID } from '../../commonStateTypes/viewAndReport/viewAndReport';
|
|
8
|
+
import { ZeniDate } from '../../zeniDayJS';
|
|
9
|
+
import { PandLReportViewCalculatedSectionID, PandLReportViewSectionID } from './profitAndLossClassesViewSelectorTypes';
|
|
10
|
+
import { ProfitAndLossClassesViewUIState } from './profitAndLossClassesViewState';
|
|
11
|
+
export interface ClassColumnDefinition {
|
|
12
|
+
classId: string;
|
|
13
|
+
className: string;
|
|
14
|
+
nestedClassId: NestedClassID;
|
|
15
|
+
qboId?: ID;
|
|
16
|
+
}
|
|
17
|
+
export interface HorizontalClassBalance {
|
|
18
|
+
balance: Amount;
|
|
19
|
+
classId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface HorizontalAccountRow {
|
|
22
|
+
accountId: string;
|
|
23
|
+
accountName: string;
|
|
24
|
+
classBalances: HorizontalClassBalance[];
|
|
25
|
+
rowTotal: Amount;
|
|
26
|
+
}
|
|
27
|
+
export interface HorizontalSectionReport {
|
|
28
|
+
accounts: HorizontalAccountRow[];
|
|
29
|
+
classTotals: HorizontalClassBalance[];
|
|
30
|
+
sectionTotal: Amount;
|
|
31
|
+
title: string;
|
|
32
|
+
}
|
|
33
|
+
export interface HorizontalCalculatedSection {
|
|
34
|
+
classTotals: HorizontalClassBalance[];
|
|
35
|
+
sectionTotal: Amount;
|
|
36
|
+
title: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ProfitAndLossByClassHorizontalReport {
|
|
39
|
+
calculatedSections: Partial<Record<PandLReportViewCalculatedSectionID, HorizontalCalculatedSection>>;
|
|
40
|
+
classColumns: ClassColumnDefinition[];
|
|
41
|
+
fetchState: FetchState;
|
|
42
|
+
firstMonthOfFY: Month;
|
|
43
|
+
/** Synthetic COABalance array for header rendering — one per class column + total */
|
|
44
|
+
headerBalances: COABalance[];
|
|
45
|
+
idsInOrder: (PandLReportViewSectionID | PandLReportViewCalculatedSectionID)[];
|
|
46
|
+
reportId: ReportID;
|
|
47
|
+
reportTitle: string;
|
|
48
|
+
sections: Partial<Record<PandLReportViewSectionID, HorizontalSectionReport>>;
|
|
49
|
+
selectedPeriod: {
|
|
50
|
+
endDate: ZeniDate;
|
|
51
|
+
startDate: ZeniDate;
|
|
52
|
+
label?: string;
|
|
53
|
+
} | undefined;
|
|
54
|
+
uiState: ProfitAndLossClassesViewUIState;
|
|
55
|
+
bookCloseDate?: ZeniDate;
|
|
56
|
+
dataAvailable?: DataAvailable;
|
|
57
|
+
}
|
|
@@ -2,7 +2,7 @@ import { NestedClassID } from '../../commonStateTypes/classesView/nestedClassID'
|
|
|
2
2
|
import { AccountViewMode, ID } from '../../commonStateTypes/common';
|
|
3
3
|
import { ZeniAPIStatus, ZeniReportData } from '../../responsePayload';
|
|
4
4
|
import { ProfitAndLossClassesViewPayload } from './profitAndLossClassesViewPayload';
|
|
5
|
-
import { ProfitAndLossClassesViewState } from './profitAndLossClassesViewState';
|
|
5
|
+
import { ClassViewLayout, ProfitAndLossClassesViewState } from './profitAndLossClassesViewState';
|
|
6
6
|
export declare const initialState: ProfitAndLossClassesViewState;
|
|
7
7
|
export declare const fetchProfitAndLossClassesView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: boolean | undefined], {
|
|
8
8
|
cacheOverride: boolean;
|
|
@@ -30,6 +30,8 @@ export declare const fetchProfitAndLossClassesView: import("@reduxjs/toolkit").A
|
|
|
30
30
|
};
|
|
31
31
|
}, "profitAndLossClassesView/updateProfitAndLossClassesViewUIState">, updateAccountViewMode: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
32
32
|
viewMode: AccountViewMode;
|
|
33
|
-
}, "profitAndLossClassesView/updateAccountViewMode">,
|
|
33
|
+
}, "profitAndLossClassesView/updateAccountViewMode">, updateClassViewLayout: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
34
|
+
classViewLayout: ClassViewLayout;
|
|
35
|
+
}, "profitAndLossClassesView/updateClassViewLayout">, resetProfitAndLossClassesNodeCollapseState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"profitAndLossClassesView/resetProfitAndLossClassesNodeCollapseState">, clearProfitAndLossClassesView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"profitAndLossClassesView/clearProfitAndLossClassesView">;
|
|
34
36
|
declare const _default: import("redux").Reducer<ProfitAndLossClassesViewState>;
|
|
35
37
|
export default _default;
|