@zeniai/client-epic-state 5.2.10 → 5.2.11-betaRD1
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/commonStateTypes/selectorTypes/pickAndMergeForecastSection.d.ts +0 -0
- package/lib/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +1 -0
- package/lib/entity/invoicing/coupon/couponConstants.d.ts +11 -0
- package/lib/entity/invoicing/coupon/couponConstants.js +29 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +1 -0
- package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
- package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +66 -1
- package/lib/entity/jeSchedules/jeSchedulesPayload.js +135 -0
- package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +4 -2
- package/lib/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +11 -2
- package/lib/entity/jeSchedules/jeSchedulesSelector.js +38 -3
- package/lib/entity/jeSchedules/jeSchedulesState.d.ts +79 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +24 -1
- package/lib/entity/jeSchedules/jeSchedulesTypes.js +88 -1
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +2 -0
- package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +2 -0
- package/lib/epic.d.ts +9 -1
- package/lib/epic.js +16 -0
- package/lib/esm/commonStateTypes/selectorTypes/pickAndMergeForecastSection.js +1 -0
- package/lib/esm/entity/invoicing/coupon/couponConstants.js +26 -0
- package/lib/esm/entity/jeSchedules/jeScheduleHelper.js +6 -0
- package/lib/esm/entity/jeSchedules/jeSchedulesPayload.js +135 -1
- package/lib/esm/entity/jeSchedules/jeSchedulesReducer.js +30 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesSelector.js +36 -2
- package/lib/esm/entity/jeSchedules/jeSchedulesTypes.js +78 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +3 -0
- package/lib/esm/entity/transaction/payloadTypes/scheduleTransactionPayload.js +2 -0
- package/lib/esm/epic.js +16 -0
- package/lib/esm/index.js +14 -8
- package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
- package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
- package/lib/esm/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
- package/lib/esm/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
- package/lib/esm/view/companyMonthEndReportView/monthEndTemplateData.js +32 -0
- package/lib/esm/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +41 -5
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +45 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +99 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +25 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +110 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +79 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +139 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +106 -0
- package/lib/esm/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +22 -0
- package/lib/esm/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +140 -0
- package/lib/esm/view/expenseAutomationView/payload/jeSchedulesPayload.js +55 -0
- package/lib/esm/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +306 -29
- package/lib/esm/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +1 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +106 -0
- package/lib/esm/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +294 -22
- package/lib/esm/view/expenseAutomationView/types/jeSchedulesViewState.js +5 -6
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +25 -0
- package/lib/esm/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +15 -0
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/esm/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/esm/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +18 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +18 -0
- package/lib/esm/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +18 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +16 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +1 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +60 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +12 -0
- package/lib/esm/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +1 -0
- package/lib/index.d.ts +19 -13
- package/lib/index.js +91 -47
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewPayload.d.ts +8 -0
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.d.ts +6 -2
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.d.ts +2 -0
- package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
- package/lib/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
- package/lib/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
- package/lib/view/companyMonthEndReportView/monthEndTemplateData.d.ts +16 -0
- package/lib/view/companyMonthEndReportView/monthEndTemplateData.js +36 -0
- package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +6 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.d.ts +3 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchJeSchedulesEpic.js +39 -3
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.d.ts +20 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/fetchOneTimeAccrualEpic.js +49 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/ignoreRecommendedJeScheduleEpic.js +14 -2
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js +103 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js +29 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.d.ts +45 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/saveNewScheduleEpic.js +114 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.d.ts +8 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/searchTransactionsForNewScheduleEpic.js +83 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.d.ts +12 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/oneTimeAccrualActionsEpic.js +146 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.d.ts +64 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/revertJeScheduleEpic.js +110 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.d.ts +6 -0
- package/lib/view/expenseAutomationView/epics/jeSchedule/switchJESchedulesTabEpic.js +26 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.d.ts +36 -0
- package/lib/view/expenseAutomationView/helpers/newScheduleLocalDataHelper.js +145 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.d.ts +72 -3
- package/lib/view/expenseAutomationView/payload/jeSchedulesPayload.js +58 -1
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.d.ts +91 -12
- package/lib/view/expenseAutomationView/reducers/jeSchedulesViewReducer.js +308 -29
- package/lib/view/expenseAutomationView/reducers/missingReceiptsViewReducer.d.ts +1 -1
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +2 -2
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.d.ts +42 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeNewScheduleViewSelectorTypes.js +2 -0
- package/lib/view/expenseAutomationView/selectorTypes/jeSchedulesSelectorTypes.d.ts +36 -7
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.d.ts +21 -0
- package/lib/view/expenseAutomationView/selectors/jeNewScheduleViewSelector.js +112 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.d.ts +34 -0
- package/lib/view/expenseAutomationView/selectors/jeSchedulesViewSelector.js +302 -21
- package/lib/view/expenseAutomationView/types/completedSubTab.d.ts +1 -1
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.d.ts +82 -8
- package/lib/view/expenseAutomationView/types/jeSchedulesViewState.js +8 -8
- package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboAccountsEpic.js +29 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.d.ts +6 -0
- package/lib/view/invoicing/invoicingQboView/epics/fetchInvoicingQboClassesEpic.js +19 -0
- package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +1 -1
- package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +4 -2
- package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +5 -3
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoIntroClosedByOutsideClickEpic.js +22 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryPromoRemindMeLaterClickedEpic.js +22 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.d.ts +8 -0
- package/lib/view/spendManagement/treasury/treasurySetUp/epic/updateTreasuryVideoViewedEpic.js +22 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.d.ts +13 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardEpic.js +20 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.d.ts +11 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardPayload.js +2 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.d.ts +7 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardReducer.js +64 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.d.ts +12 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardSelector.js +15 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.d.ts +9 -0
- package/lib/view/zeniAccountsPromoCard/zeniAccountsPromoCardState.js +2 -0
- package/package.json +1 -1
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { AttachmentFilePayload } from '../../entity/file/filePayload';
|
|
2
2
|
import { ZeniAPIResponse } from '../../responsePayload';
|
|
3
3
|
export type MonthEndTemplateData = Record<string, unknown>;
|
|
4
|
+
/**
|
|
5
|
+
* The AI CFO insight fields a controller can edit before the month-end email
|
|
6
|
+
* is sent. Keys are the `agent_insights_*` merge vars the email template
|
|
7
|
+
* renders from, so this object is merged straight into `template_data`.
|
|
8
|
+
*/
|
|
9
|
+
export type AgentInsightEdits = Record<`agent_insights_${string}`, string>;
|
|
4
10
|
export interface CompanyMonthEndReportViewPayload {
|
|
5
11
|
files: AttachmentFilePayload[];
|
|
6
12
|
html: string | null;
|
|
@@ -9,6 +15,8 @@ export interface CompanyMonthEndReportViewPayload {
|
|
|
9
15
|
template_data: MonthEndTemplateData;
|
|
10
16
|
tenant_receiver_email_list: string[];
|
|
11
17
|
zeni_requests_data: string[];
|
|
18
|
+
agent_insights_edited_at?: string | null;
|
|
19
|
+
agent_insights_edited_by?: string | null;
|
|
12
20
|
draft_user_id?: string;
|
|
13
21
|
last_month_end_email_draft_saved_at?: string;
|
|
14
22
|
zeni_requests_html?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FetchState, FetchStateAndError, ID } from '../../commonStateTypes/common';
|
|
2
2
|
import { ZeniAPIStatus } from '../../responsePayload';
|
|
3
3
|
import { ZeniDate } from '../../zeniDayJS';
|
|
4
|
-
import { CompanyMonthEndHistoricReportPayload, CompanyMonthEndReportHistoricDatesPayload, CompanyMonthEndReportTemplatesPayload, CompanyMonthEndReportViewPayload } from './companyMonthEndReportViewPayload';
|
|
4
|
+
import { AgentInsightEdits, CompanyMonthEndHistoricReportPayload, CompanyMonthEndReportHistoricDatesPayload, CompanyMonthEndReportTemplatesPayload, CompanyMonthEndReportViewPayload } from './companyMonthEndReportViewPayload';
|
|
5
5
|
import { AuditSummaryData, CompanyMonthEndReportData, CompanyMonthEndReportViewState, CompanyMonthReportTemplates } from './companyMonthEndReportViewState';
|
|
6
6
|
export declare const initialState: CompanyMonthEndReportViewState;
|
|
7
7
|
export declare const initialCompanyMonthEndReportData: CompanyMonthEndReportData;
|
|
@@ -35,7 +35,10 @@ export declare const fetchImproveUsingZeniGPT: import("@reduxjs/toolkit").Action
|
|
|
35
35
|
companyId: string;
|
|
36
36
|
fileId: string | undefined;
|
|
37
37
|
tenantId: string | undefined;
|
|
38
|
-
}, "reviewCompanyView/sendCompanyMonthEndReport", never, never>, saveCompanyMonthEndReport: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[recipientEmailList: any, companyId: string, subject: string, isPreview: boolean, fileId?: string | undefined, zeniRequestsHtml?: string | undefined,
|
|
38
|
+
}, "reviewCompanyView/sendCompanyMonthEndReport", never, never>, saveCompanyMonthEndReport: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[recipientEmailList: any, companyId: string, subject: string, isPreview: boolean, fileId?: string | undefined, zeniRequestsHtml?: string | undefined, options?: {
|
|
39
|
+
agentInsightEdits?: AgentInsightEdits;
|
|
40
|
+
tenantId?: ID;
|
|
41
|
+
} | undefined], {
|
|
39
42
|
recipientEmailList: any;
|
|
40
43
|
companyId: string;
|
|
41
44
|
subject: string;
|
|
@@ -43,6 +46,7 @@ export declare const fetchImproveUsingZeniGPT: import("@reduxjs/toolkit").Action
|
|
|
43
46
|
fileId: string | undefined;
|
|
44
47
|
zeniRequestsHtml: string | undefined;
|
|
45
48
|
tenantId: string | undefined;
|
|
49
|
+
agentInsightEdits: AgentInsightEdits | undefined;
|
|
46
50
|
}, "reviewCompanyView/saveCompanyMonthEndReport", never, never>, updateStatusForSendCompanyMonthEndReport: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[companyId: string, status: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
|
|
47
51
|
companyId: string;
|
|
48
52
|
status: FetchState;
|
|
@@ -99,7 +99,10 @@ const companyMonthEndReportView = (0, toolkit_1.createSlice)({
|
|
|
99
99
|
},
|
|
100
100
|
},
|
|
101
101
|
saveCompanyMonthEndReport: {
|
|
102
|
-
|
|
102
|
+
// The trailing pair is an object, not two more positional optionals: both
|
|
103
|
+
// are optional and neither is a distinct type, so a swapped call would
|
|
104
|
+
// compile silently.
|
|
105
|
+
prepare(recipientEmailList, companyId, subject, isPreview, fileId, zeniRequestsHtml, options) {
|
|
103
106
|
return {
|
|
104
107
|
payload: {
|
|
105
108
|
recipientEmailList,
|
|
@@ -108,7 +111,8 @@ const companyMonthEndReportView = (0, toolkit_1.createSlice)({
|
|
|
108
111
|
isPreview,
|
|
109
112
|
fileId,
|
|
110
113
|
zeniRequestsHtml,
|
|
111
|
-
tenantId,
|
|
114
|
+
tenantId: options?.tenantId,
|
|
115
|
+
agentInsightEdits: options?.agentInsightEdits,
|
|
112
116
|
},
|
|
113
117
|
};
|
|
114
118
|
},
|
|
@@ -5,6 +5,8 @@ import { AuditSummary } from '../reviewCompanyView/reviewCompanyViewState';
|
|
|
5
5
|
import { CompanyMonthEndHistoricReportPayload, CompanyMonthEndReportViewPayload, MonthEndTemplateData } from './companyMonthEndReportViewPayload';
|
|
6
6
|
export interface CompanyMonthEndReportData {
|
|
7
7
|
recipientEmailList: string[];
|
|
8
|
+
agentInsightsEditedAt?: ZeniDate;
|
|
9
|
+
agentInsightsEditedBy?: string;
|
|
8
10
|
attachmentFile?: AttachmentFile;
|
|
9
11
|
concatenatedHtml?: string;
|
|
10
12
|
draftUserId?: string;
|
|
@@ -23,6 +23,10 @@ const toCompanyMonthEndReportData = (data) => {
|
|
|
23
23
|
: undefined,
|
|
24
24
|
draftUserId: data.draft_user_id,
|
|
25
25
|
zeniRequestsData: data.zeni_requests_data ?? [],
|
|
26
|
+
agentInsightsEditedBy: data.agent_insights_edited_by ?? undefined,
|
|
27
|
+
agentInsightsEditedAt: data.agent_insights_edited_at != null
|
|
28
|
+
? (0, zeniDayJS_1.date)(data.agent_insights_edited_at)
|
|
29
|
+
: undefined,
|
|
26
30
|
};
|
|
27
31
|
};
|
|
28
32
|
exports.toCompanyMonthEndReportData = toCompanyMonthEndReportData;
|
|
@@ -9,9 +9,10 @@ const fileSelector_1 = require("../../../entity/file/fileSelector");
|
|
|
9
9
|
const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
10
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
11
11
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
12
|
+
const monthEndTemplateData_1 = require("../monthEndTemplateData");
|
|
12
13
|
const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
|
|
13
14
|
const saveCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.saveCompanyMonthEndReport.match), (0, operators_1.mergeMap)((action) => {
|
|
14
|
-
const { companyId, recipientEmailList, subject, isPreview, fileId, zeniRequestsHtml, tenantId, } = action.payload;
|
|
15
|
+
const { agentInsightEdits, companyId, recipientEmailList, subject, isPreview, fileId, zeniRequestsHtml, tenantId, } = action.payload;
|
|
15
16
|
const state = state$.value;
|
|
16
17
|
const company = state.companyState.companiesById[companyId];
|
|
17
18
|
const companyName = state.companyState.companiesById[companyId].companyInfo.name;
|
|
@@ -30,15 +31,18 @@ const saveCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pi
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
const payload = {
|
|
33
|
-
template_data:
|
|
34
|
-
...state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData,
|
|
35
|
-
subject,
|
|
36
|
-
},
|
|
34
|
+
template_data: (0, monthEndTemplateData_1.buildMonthEndTemplateData)(state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData, subject, agentInsightEdits),
|
|
37
35
|
recipient_email_list: recipientEmailList,
|
|
38
36
|
tenant_receiver_email_list: state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.tenantReceiverEmailList,
|
|
39
37
|
last_report_sent_business_day: lastReportSentBusinessDay,
|
|
40
38
|
last_report_sent_date: lastReportSentDate.format(timePeriod_1.DEFAULT_DATE_FORMAT),
|
|
41
|
-
|
|
39
|
+
// Three-way, because the server distinguishes all three: an empty string means the user
|
|
40
|
+
// cleared the box and is sent as an explicit null, a value is sent as-is, and undefined
|
|
41
|
+
// means this save was not about Zeni Requests at all — the key is omitted so the draft's
|
|
42
|
+
// existing text is left alone.
|
|
43
|
+
...(zeniRequestsHtml !== undefined && {
|
|
44
|
+
zeni_requests_html: zeniRequestsHtml === '' ? null : zeniRequestsHtml,
|
|
45
|
+
}),
|
|
42
46
|
files: filePayload,
|
|
43
47
|
};
|
|
44
48
|
const query = { is_preview: isPreview };
|
|
@@ -10,6 +10,7 @@ const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
|
|
|
10
10
|
const responsePayload_1 = require("../../../responsePayload");
|
|
11
11
|
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
12
12
|
const companyViewReducer_1 = require("../../companyView/companyViewReducer");
|
|
13
|
+
const monthEndTemplateData_1 = require("../monthEndTemplateData");
|
|
13
14
|
const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
|
|
14
15
|
const sendCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.sendCompanyMonthEndReport.match), (0, operators_1.mergeMap)((action) => {
|
|
15
16
|
const { companyId, fileId, tenantId } = action.payload;
|
|
@@ -34,15 +35,18 @@ const sendCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pi
|
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
const payload = {
|
|
37
|
-
template_data:
|
|
38
|
-
...state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData,
|
|
39
|
-
subject,
|
|
40
|
-
},
|
|
38
|
+
template_data: (0, monthEndTemplateData_1.buildMonthEndTemplateData)(state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData, subject),
|
|
41
39
|
recipient_email_list: recipientEmailList,
|
|
42
40
|
tenant_receiver_email_list: state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.tenantReceiverEmailList,
|
|
43
41
|
last_report_sent_business_day: lastReportSentBusinessDay,
|
|
44
42
|
last_report_sent_date: lastReportSentDate.format(timePeriod_1.DEFAULT_DATE_FORMAT),
|
|
45
|
-
|
|
43
|
+
// Three-way, because the server distinguishes all three: an empty string means the user
|
|
44
|
+
// cleared the box and is sent as an explicit null, a value is sent as-is, and undefined
|
|
45
|
+
// means this save was not about Zeni Requests at all — the key is omitted so the draft's
|
|
46
|
+
// existing text is left alone.
|
|
47
|
+
...(zeniRequestsHtml !== undefined && {
|
|
48
|
+
zeni_requests_html: zeniRequestsHtml === '' ? null : zeniRequestsHtml,
|
|
49
|
+
}),
|
|
46
50
|
files: filePayload,
|
|
47
51
|
};
|
|
48
52
|
return zeniAPI
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AgentInsightEdits, MonthEndTemplateData } from './companyMonthEndReportViewPayload';
|
|
2
|
+
/**
|
|
3
|
+
* The AI CFO (V2) month-end email renders its subject line from this merge var
|
|
4
|
+
* rather than from the generic `subject` key, so a subject typed in the cockpit
|
|
5
|
+
* has to be written here too or the sent email keeps the AI's original subject.
|
|
6
|
+
*/
|
|
7
|
+
export declare const AGENT_INSIGHTS_SUBJECT_KEY = "agent_insights_subject";
|
|
8
|
+
/**
|
|
9
|
+
* Build the `template_data` sent to the month-end email endpoint.
|
|
10
|
+
*
|
|
11
|
+
* Controller edits to the AI-generated insight fields are merged over the
|
|
12
|
+
* template data held in the store. The server sanitizes and persists whichever
|
|
13
|
+
* `agent_insights_*` keys are present, and the send path renders from the
|
|
14
|
+
* persisted draft — so only a save (`is_preview: false`) makes an edit stick.
|
|
15
|
+
*/
|
|
16
|
+
export declare const buildMonthEndTemplateData: (templateData: MonthEndTemplateData | undefined, subject: string | undefined, agentInsightEdits?: AgentInsightEdits) => MonthEndTemplateData;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildMonthEndTemplateData = exports.AGENT_INSIGHTS_SUBJECT_KEY = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The AI CFO (V2) month-end email renders its subject line from this merge var
|
|
6
|
+
* rather than from the generic `subject` key, so a subject typed in the cockpit
|
|
7
|
+
* has to be written here too or the sent email keeps the AI's original subject.
|
|
8
|
+
*/
|
|
9
|
+
exports.AGENT_INSIGHTS_SUBJECT_KEY = 'agent_insights_subject';
|
|
10
|
+
/**
|
|
11
|
+
* Build the `template_data` sent to the month-end email endpoint.
|
|
12
|
+
*
|
|
13
|
+
* Controller edits to the AI-generated insight fields are merged over the
|
|
14
|
+
* template data held in the store. The server sanitizes and persists whichever
|
|
15
|
+
* `agent_insights_*` keys are present, and the send path renders from the
|
|
16
|
+
* persisted draft — so only a save (`is_preview: false`) makes an edit stick.
|
|
17
|
+
*/
|
|
18
|
+
const buildMonthEndTemplateData = (templateData, subject, agentInsightEdits) => {
|
|
19
|
+
const merged = {
|
|
20
|
+
...templateData,
|
|
21
|
+
...agentInsightEdits,
|
|
22
|
+
subject,
|
|
23
|
+
};
|
|
24
|
+
// Only for AI CFO drafts (the key is absent on legacy ones), never over an
|
|
25
|
+
// explicit edit to the field itself, and never with an empty value — on send
|
|
26
|
+
// the subject comes from store state and can be absent, which must not blank
|
|
27
|
+
// the AI's subject line.
|
|
28
|
+
if (exports.AGENT_INSIGHTS_SUBJECT_KEY in merged &&
|
|
29
|
+
agentInsightEdits?.[exports.AGENT_INSIGHTS_SUBJECT_KEY] == null &&
|
|
30
|
+
subject != null &&
|
|
31
|
+
subject !== '') {
|
|
32
|
+
merged[exports.AGENT_INSIGHTS_SUBJECT_KEY] = subject;
|
|
33
|
+
}
|
|
34
|
+
return merged;
|
|
35
|
+
};
|
|
36
|
+
exports.buildMonthEndTemplateData = buildMonthEndTemplateData;
|
|
@@ -11,6 +11,7 @@ const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer"
|
|
|
11
11
|
const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
|
|
12
12
|
const reconciliationViewReducer_1 = require("../../reducers/reconciliationViewReducer");
|
|
13
13
|
const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
|
|
14
|
+
const jeSchedulesViewState_1 = require("../../types/jeSchedulesViewState");
|
|
14
15
|
const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(expenseAutomationViewReducer_1.fetchAllExpenseAutomationTabs.match), (0, operators_1.switchMap)((action) => {
|
|
15
16
|
const { cacheOverride, refreshViewInBackground } = action.payload;
|
|
16
17
|
const state = state$.value;
|
|
@@ -62,14 +63,16 @@ const fetchAllExpenseAutomationTabsEpic = (actions$, state$) => actions$.pipe((0
|
|
|
62
63
|
state.expenseAutomationFluxAnalysisViewState.groupsBySelectedPeriod[monthYearPeriodId] == null)) {
|
|
63
64
|
fetchActions.push((0, fluxAnalysisViewReducer_1.fetchFluxAnalysisView)(selectedPeriod, cacheOverride, refreshViewInBackground, null));
|
|
64
65
|
}
|
|
66
|
+
// The two JE tabs cache separately, so only the tab actually being shown decides whether a
|
|
67
|
+
// fetch is still needed.
|
|
68
|
+
const jeSchedulesPeriodTabKey = (0, jeSchedulesViewState_1.getJESchedulePeriodTabKey)(state.expenseAutomationJESchedulesViewState.uiState.selectedPageTab, monthYearPeriodId);
|
|
65
69
|
if (state.expenseAutomationJESchedulesViewState.fetchState !==
|
|
66
70
|
'In-Progress' &&
|
|
67
71
|
(!state.expenseAutomationJESchedulesViewState.hasValidState() ||
|
|
68
72
|
state.expenseAutomationJESchedulesViewState
|
|
69
|
-
.
|
|
73
|
+
.jeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null ||
|
|
70
74
|
state.expenseAutomationJESchedulesViewState
|
|
71
|
-
.
|
|
72
|
-
null)) {
|
|
75
|
+
.failedJeScheduleTransactionKeysByPeriodAndTab[jeSchedulesPeriodTabKey] == null)) {
|
|
73
76
|
fetchActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesPage)({ start: timePeriodStart, end: timePeriodEnd }, cacheOverride));
|
|
74
77
|
}
|
|
75
78
|
if (state.expenseAutomationReconciliationViewState.fetchState !==
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
3
|
+
import { updateAccruedJESchedules, updateAccruedJESchedulesDetails, updateJEOneTimeAccruals, updateJESchedules, updateJESchedulesDetails } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
4
|
import { RootState } from '../../../../rootStateTypes';
|
|
5
|
+
import { clearAll } from '../../../../rootActions';
|
|
5
6
|
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
7
|
import { fetchJeSchedules, fetchJeSchedulesFailure, fetchJeSchedulesSuccess, initializeJeScheduleLocalData } from '../../reducers/jeSchedulesViewReducer';
|
|
7
|
-
export type ActionType = ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesFailure> | ReturnType<typeof fetchJeSchedulesSuccess> | ReturnType<typeof initializeJeScheduleLocalData> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
|
|
8
|
+
export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof fetchJeSchedulesFailure> | ReturnType<typeof fetchJeSchedulesSuccess> | ReturnType<typeof initializeJeScheduleLocalData> | ReturnType<typeof updateAccruedJESchedules> | ReturnType<typeof updateAccruedJESchedulesDetails> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateJESchedulesDetails>;
|
|
8
9
|
export declare const fetchJeSchedulesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -4,9 +4,12 @@ exports.fetchJeSchedulesEpic = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const timePeriod_1 = require("../../../../commonStateTypes/timePeriod");
|
|
7
|
+
const timePeriod_2 = require("../../../../commonStateTypes/timePeriod");
|
|
7
8
|
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
8
9
|
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
9
10
|
const responsePayload_1 = require("../../../../responsePayload");
|
|
11
|
+
const rootActions_1 = require("../../../../rootActions");
|
|
12
|
+
const zeniDayJS_1 = require("../../../../zeniDayJS");
|
|
10
13
|
const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
|
|
11
14
|
const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.fetchJeSchedules.match), (0, operators_1.mergeMap)((action) => {
|
|
12
15
|
const state = state$.value;
|
|
@@ -14,27 +17,54 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
|
|
|
14
17
|
const { period, refreshViewInBackground } = action.payload;
|
|
15
18
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
16
19
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
20
|
+
const { selectedPageTab } = state.expenseAutomationJESchedulesViewState.uiState;
|
|
21
|
+
const isClosePeriodTab = selectedPageTab === 'schedules';
|
|
22
|
+
const existingEndDate = (0, timePeriod_2.toAbsoluteDay)((0, zeniDayJS_1.date)((0, timePeriod_2.toString)(period.start))
|
|
23
|
+
.subtract(1, 'month')
|
|
24
|
+
.endOf('month')
|
|
25
|
+
.format(timePeriod_1.DEFAULT_DATE_FORMAT));
|
|
17
26
|
const queryParam = {
|
|
18
|
-
start_date: (0,
|
|
19
|
-
end_date:
|
|
27
|
+
start_date: (0, timePeriod_2.toString)(period.start),
|
|
28
|
+
end_date: isClosePeriodTab || existingEndDate == null
|
|
29
|
+
? (0, timePeriod_2.toString)(period.end)
|
|
30
|
+
: (0, timePeriod_2.toString)(existingEndDate),
|
|
31
|
+
include_accrued: true,
|
|
32
|
+
...(isClosePeriodTab
|
|
33
|
+
? { close_period_start_date: (0, timePeriod_2.toString)(period.start) }
|
|
34
|
+
: {}),
|
|
20
35
|
};
|
|
21
36
|
return zeniAPI
|
|
22
37
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/je_schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
23
38
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
24
39
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
25
40
|
const updateActions = [];
|
|
41
|
+
const accruedJeSchedules = response.data.accrued_je_schedules?.je_schedules ?? [];
|
|
42
|
+
const oneTimeAccruals = response.data.one_time_accruals ?? [];
|
|
26
43
|
updateActions.push((0, jeSchedulesReducer_1.updateJESchedules)([
|
|
27
44
|
...response.data.je_schedules,
|
|
28
45
|
...response.data.failed_je_postings.je_schedules,
|
|
29
46
|
]), (0, jeSchedulesReducer_1.updateJESchedulesDetails)([...response.data.failed_je_postings.je_schedules], response.data.failed_je_postings.scheduled_journal_entries), (0, jeSchedulesViewReducer_1.initializeJeScheduleLocalData)([
|
|
30
47
|
...response.data.failed_je_postings.je_schedules,
|
|
31
48
|
]));
|
|
49
|
+
if (accruedJeSchedules.length > 0) {
|
|
50
|
+
updateActions.push((0, jeSchedulesReducer_1.updateAccruedJESchedules)(accruedJeSchedules), (0, jeSchedulesReducer_1.updateAccruedJESchedulesDetails)(accruedJeSchedules, response.data.accrued_je_schedules
|
|
51
|
+
?.scheduled_journal_entries));
|
|
52
|
+
}
|
|
53
|
+
if (oneTimeAccruals.length > 0) {
|
|
54
|
+
// Single action, unlike the accrued pair above: this one writes the entity
|
|
55
|
+
// directly because an accrual denormalizes its vendor, accounts and classes, so
|
|
56
|
+
// there is no fan-out fetch to trigger.
|
|
57
|
+
updateActions.push((0, jeSchedulesReducer_1.updateJEOneTimeAccruals)(oneTimeAccruals));
|
|
58
|
+
}
|
|
32
59
|
updateActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedulesSuccess)({
|
|
33
60
|
jeSchedules: [...response.data.je_schedules],
|
|
34
61
|
failedJeSchedules: [
|
|
35
62
|
...response.data.failed_je_postings.je_schedules,
|
|
36
63
|
],
|
|
64
|
+
accruedJeSchedules: accruedJeSchedules,
|
|
65
|
+
oneTimeAccruals: oneTimeAccruals,
|
|
37
66
|
selectedPeriod: selectedPeriod,
|
|
67
|
+
selectedPageTab: selectedPageTab,
|
|
38
68
|
refreshViewInBackground: refreshViewInBackground,
|
|
39
69
|
}));
|
|
40
70
|
return (0, rxjs_1.from)(updateActions);
|
|
@@ -43,12 +73,18 @@ const fetchJeSchedulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, op
|
|
|
43
73
|
return (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.fetchJeSchedulesFailure)({
|
|
44
74
|
status: response.status,
|
|
45
75
|
selectedPeriod,
|
|
76
|
+
selectedPageTab,
|
|
46
77
|
}));
|
|
47
78
|
}
|
|
48
79
|
}), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeSchedulesViewReducer_1.fetchJeSchedulesFailure)({
|
|
49
80
|
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch JE schedules REST API call errored out' +
|
|
50
81
|
JSON.stringify(error)),
|
|
51
82
|
selectedPeriod,
|
|
52
|
-
|
|
83
|
+
selectedPageTab,
|
|
84
|
+
}))),
|
|
85
|
+
// A tenant switch clears the store while this request is still in flight. Without this
|
|
86
|
+
// the old tenant's rows are written back into the freshly cleared store and stay on
|
|
87
|
+
// screen under the new tenant until a manual refresh.
|
|
88
|
+
(0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
|
|
53
89
|
}));
|
|
54
90
|
exports.fetchJeSchedulesEpic = fetchJeSchedulesEpic;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { updateJEOneTimeAccruals } from '../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
4
|
+
import { RootState } from '../../../../reducer';
|
|
5
|
+
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
+
import { fetchOneTimeAccrual, fetchOneTimeAccrualFailure, fetchOneTimeAccrualSuccess } from '../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof fetchOneTimeAccrual> | ReturnType<typeof fetchOneTimeAccrualFailure> | ReturnType<typeof fetchOneTimeAccrualSuccess> | ReturnType<typeof updateJEOneTimeAccruals>;
|
|
8
|
+
/**
|
|
9
|
+
* Read one accrual by id so its detail page can render from a URL alone.
|
|
10
|
+
*
|
|
11
|
+
* Every other row on this page arrives with the JE Schedules list, and the accrual detail page used
|
|
12
|
+
* to render only from what that list had already put in the store -- so opening its URL directly, on
|
|
13
|
+
* a refresh or a shared link, had nothing to render and showed not-found. This is the read that
|
|
14
|
+
* makes the URL self-sufficient.
|
|
15
|
+
*
|
|
16
|
+
* The response is the same `{accrual}` envelope promote / ignore / revert return, and it goes through
|
|
17
|
+
* the same `updateJEOneTimeAccruals`, so a page loaded cold holds exactly the entity a page reached
|
|
18
|
+
* through the list holds.
|
|
19
|
+
*/
|
|
20
|
+
export declare const fetchOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchOneTimeAccrualEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
7
|
+
const responsePayload_1 = require("../../../../responsePayload");
|
|
8
|
+
const rootActions_1 = require("../../../../rootActions");
|
|
9
|
+
const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer");
|
|
10
|
+
/**
|
|
11
|
+
* Read one accrual by id so its detail page can render from a URL alone.
|
|
12
|
+
*
|
|
13
|
+
* Every other row on this page arrives with the JE Schedules list, and the accrual detail page used
|
|
14
|
+
* to render only from what that list had already put in the store -- so opening its URL directly, on
|
|
15
|
+
* a refresh or a shared link, had nothing to render and showed not-found. This is the read that
|
|
16
|
+
* makes the URL self-sufficient.
|
|
17
|
+
*
|
|
18
|
+
* The response is the same `{accrual}` envelope promote / ignore / revert return, and it goes through
|
|
19
|
+
* the same `updateJEOneTimeAccruals`, so a page loaded cold holds exactly the entity a page reached
|
|
20
|
+
* through the list holds.
|
|
21
|
+
*/
|
|
22
|
+
const fetchOneTimeAccrualEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.fetchOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
|
|
23
|
+
const { accrualId } = action.payload;
|
|
24
|
+
return zeniAPI
|
|
25
|
+
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${accrualId}`)
|
|
26
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
27
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
28
|
+
return (0, rxjs_1.from)([
|
|
29
|
+
(0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
|
|
30
|
+
(0, jeSchedulesViewReducer_1.fetchOneTimeAccrualSuccess)({ accrualId }),
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
// A deleted or ignored accrual answers 404 here, the same as an id that never existed.
|
|
34
|
+
// Both end as an error state the page turns into not-found, rather than a spinner that
|
|
35
|
+
// never resolves.
|
|
36
|
+
return (0, rxjs_1.from)([
|
|
37
|
+
(0, jeSchedulesViewReducer_1.fetchOneTimeAccrualFailure)({ accrualId, status: response.status }),
|
|
38
|
+
]);
|
|
39
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
40
|
+
(0, jeSchedulesViewReducer_1.fetchOneTimeAccrualFailure)({
|
|
41
|
+
accrualId,
|
|
42
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Fetch one-time accrual REST API call errored out ${JSON.stringify(error)}`),
|
|
43
|
+
}),
|
|
44
|
+
])),
|
|
45
|
+
// A tenant switch clears the store while this request is in flight. Without this the old
|
|
46
|
+
// tenant's accrual is written back into the freshly cleared store.
|
|
47
|
+
(0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))));
|
|
48
|
+
}));
|
|
49
|
+
exports.fetchOneTimeAccrualEpic = fetchOneTimeAccrualEpic;
|
|
@@ -14,13 +14,25 @@ const jeSchedulesViewReducer_1 = require("../../reducers/jeSchedulesViewReducer"
|
|
|
14
14
|
const ignoreRecommendedJeScheduleEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.ignoreRecommendedJeSchedule.match), (0, operators_1.mergeMap)((action) => {
|
|
15
15
|
const state = state$.value;
|
|
16
16
|
const { expenseAutomationViewState: { selectedPeriodByTenantId }, } = state;
|
|
17
|
-
const { scheduleType, jeScheduleTransactionKey } = action.payload;
|
|
17
|
+
const { scheduleType, jeScheduleTransactionKey, reason, note } = action.payload;
|
|
18
18
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
19
19
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
20
20
|
const actions = [];
|
|
21
21
|
const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleTransactionKey)(jeScheduleTransactionKey, state);
|
|
22
|
+
const ignorePayload = (0, jeSchedulesPayload_1.prepareIgnoreSchedulePayload)(scheduleType, jeScheduleTransactionState, state);
|
|
23
|
+
// The gateway reads reason/note from je_schedules[0].feedback and nowhere else, and rejects
|
|
24
|
+
// anything but those two keys inside it — `action` is stamped server-side.
|
|
22
25
|
const payload = {
|
|
23
|
-
...
|
|
26
|
+
...ignorePayload,
|
|
27
|
+
je_schedules: ignorePayload.je_schedules.map((schedule, index) => index === 0
|
|
28
|
+
? {
|
|
29
|
+
...schedule,
|
|
30
|
+
feedback: {
|
|
31
|
+
reason,
|
|
32
|
+
...(note != null && note !== '' ? { note } : {}),
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
: schedule),
|
|
24
36
|
};
|
|
25
37
|
const queryParam = {
|
|
26
38
|
je_schedule_type: scheduleType,
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { updateJEOneTimeAccruals } from '../../../../../entity/jeSchedules/jeSchedulesReducer';
|
|
3
|
+
import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
4
|
+
import { RootState } from '../../../../../reducer';
|
|
5
|
+
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
6
|
+
import { createOneTimeAccrual, createOneTimeAccrualFailure, createOneTimeAccrualSuccess, fetchJeSchedules } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof createOneTimeAccrual> | ReturnType<typeof createOneTimeAccrualSuccess> | ReturnType<typeof createOneTimeAccrualFailure> | ReturnType<typeof updateJEOneTimeAccruals> | ReturnType<typeof fetchJeSchedules> | ReturnType<typeof openSnackbar>;
|
|
8
|
+
export declare const createOneTimeAccrualEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/createOneTimeAccrualEpic.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createOneTimeAccrualEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const timePeriod_1 = require("../../../../../commonStateTypes/timePeriod");
|
|
7
|
+
const jeSchedulesReducer_1 = require("../../../../../entity/jeSchedules/jeSchedulesReducer");
|
|
8
|
+
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
9
|
+
const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
|
|
10
|
+
const responsePayload_1 = require("../../../../../responsePayload");
|
|
11
|
+
const jeSchedulesPayload_1 = require("../../../payload/jeSchedulesPayload");
|
|
12
|
+
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
13
|
+
const createOneTimeAccrualEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.createOneTimeAccrual.match), (0, operators_1.mergeMap)((action) => {
|
|
14
|
+
const state = state$.value;
|
|
15
|
+
const { localData } = action.payload;
|
|
16
|
+
/*
|
|
17
|
+
* Idempotency for the create. agent-je dedupes on this: the same key again returns the
|
|
18
|
+
* existing accrual rather than posting a second JE to QBO.
|
|
19
|
+
*
|
|
20
|
+
* Body `request_id` rather than the `Idempotency-Key` header the API doc prefers, on Mohit's
|
|
21
|
+
* call (2026-08-24). The header cannot reach the service from a browser -- common's
|
|
22
|
+
* Access-Control-Allow-Headers does not list it, so cross-origin preflight rejects the
|
|
23
|
+
* request. Same meaning either way; the header simply wins when both are sent.
|
|
24
|
+
*
|
|
25
|
+
* Minted here, per create action, and deliberately not held in local data or the form: a new
|
|
26
|
+
* Save must produce a new key, and only a retry of *this* request may reuse one. Nothing
|
|
27
|
+
* retries today -- if a retry operator is ever added below, it has to sit inside this
|
|
28
|
+
* mergeMap so the key is not re-minted, or the guarantee is silently lost.
|
|
29
|
+
*/
|
|
30
|
+
const requestId = crypto.randomUUID();
|
|
31
|
+
const payload = {
|
|
32
|
+
...(0, jeSchedulesPayload_1.prepareCreateOneTimeAccrualPayload)(state, localData),
|
|
33
|
+
request_id: requestId,
|
|
34
|
+
};
|
|
35
|
+
// convertToPeriod destructures, so an unset period would throw here and take the epic
|
|
36
|
+
// subscription down for the whole session — a missed refresh is the cheaper failure.
|
|
37
|
+
const selectedMonthYear = state.expenseAutomationViewState.selectedPeriodByTenantId[(0, tenantSelector_1.getCurrentTenant)(state).tenantId];
|
|
38
|
+
const selectedPeriod = selectedMonthYear != null
|
|
39
|
+
? (0, timePeriod_1.convertToPeriod)(selectedMonthYear)
|
|
40
|
+
: undefined;
|
|
41
|
+
const periodStart = selectedPeriod != null
|
|
42
|
+
? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.start)
|
|
43
|
+
: undefined;
|
|
44
|
+
const periodEnd = selectedPeriod != null ? (0, timePeriod_1.toAbsoluteDay)(selectedPeriod.end) : undefined;
|
|
45
|
+
return zeniAPI
|
|
46
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`, payload)
|
|
47
|
+
.pipe((0, operators_1.mergeMap)((response) => {
|
|
48
|
+
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
49
|
+
const successActions = [
|
|
50
|
+
(0, jeSchedulesReducer_1.updateJEOneTimeAccruals)([response.data.accrual]),
|
|
51
|
+
(0, jeSchedulesViewReducer_1.createOneTimeAccrualSuccess)(),
|
|
52
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
53
|
+
messageSection: 'create_schedule',
|
|
54
|
+
messageText: 'success',
|
|
55
|
+
type: 'success',
|
|
56
|
+
variables: [
|
|
57
|
+
{
|
|
58
|
+
variableName: '_vendor_name_',
|
|
59
|
+
variableValue: localData.vendorName,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
}),
|
|
63
|
+
];
|
|
64
|
+
// The tab buckets (jeScheduleOneTimeAccrualKeysByPeriodAndTab) are rebuilt wholesale
|
|
65
|
+
// per fetch, and the backend decides whether a freshly posted accrual belongs to
|
|
66
|
+
// Review or Existing — so refetch rather than guess which bucket to insert into.
|
|
67
|
+
if (periodStart != null && periodEnd != null) {
|
|
68
|
+
successActions.push((0, jeSchedulesViewReducer_1.fetchJeSchedules)({ start: periodStart, end: periodEnd }, true));
|
|
69
|
+
}
|
|
70
|
+
return (0, rxjs_1.from)(successActions);
|
|
71
|
+
}
|
|
72
|
+
return (0, rxjs_1.from)([
|
|
73
|
+
(0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({ status: response.status }),
|
|
74
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
75
|
+
messageSection: 'create_schedule',
|
|
76
|
+
messageText: 'failed',
|
|
77
|
+
type: 'error',
|
|
78
|
+
variables: [
|
|
79
|
+
{
|
|
80
|
+
variableName: '_api-error_',
|
|
81
|
+
variableValue: response.status.message,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
}),
|
|
85
|
+
]);
|
|
86
|
+
}), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
|
|
87
|
+
(0, snackbarReducer_1.openSnackbar)({
|
|
88
|
+
messageSection: 'create_schedule',
|
|
89
|
+
messageText: 'failed',
|
|
90
|
+
type: 'error',
|
|
91
|
+
variables: [
|
|
92
|
+
{
|
|
93
|
+
variableName: '_api-error_',
|
|
94
|
+
variableValue: JSON.stringify(error),
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
}),
|
|
98
|
+
(0, jeSchedulesViewReducer_1.createOneTimeAccrualFailure)({
|
|
99
|
+
status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Create One Time Accrual REST API call errored out ${JSON.stringify(error)}`),
|
|
100
|
+
}),
|
|
101
|
+
])));
|
|
102
|
+
}));
|
|
103
|
+
exports.createOneTimeAccrualEpic = createOneTimeAccrualEpic;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { RootState } from '../../../../../reducer';
|
|
4
|
+
import { fetchAccountList } from '../../../../accountList/accountListReducer';
|
|
5
|
+
import { fetchClassList } from '../../../../classList/classListReducer';
|
|
6
|
+
import { clearSearchTransactionsForNewSchedule, initializeNewSchedule, resetNewScheduleLocalData } from '../../../reducers/jeSchedulesViewReducer';
|
|
7
|
+
export type ActionType = ReturnType<typeof clearSearchTransactionsForNewSchedule> | ReturnType<typeof fetchAccountList> | ReturnType<typeof fetchClassList> | ReturnType<typeof initializeNewSchedule> | ReturnType<typeof resetNewScheduleLocalData>;
|
|
8
|
+
export declare const initializeNewScheduleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
package/lib/view/expenseAutomationView/epics/jeSchedule/newSchedule/initializeNewScheduleEpic.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initializeNewScheduleEpic = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const accountListReducer_1 = require("../../../../accountList/accountListReducer");
|
|
7
|
+
const classListReducer_1 = require("../../../../classList/classListReducer");
|
|
8
|
+
const scheduleListHelper_1 = require("../../../../scheduleView/scheduleListView/scheduleListHelper");
|
|
9
|
+
const jeSchedulesViewReducer_1 = require("../../../reducers/jeSchedulesViewReducer");
|
|
10
|
+
const initializeNewScheduleEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(jeSchedulesViewReducer_1.initializeNewSchedule.match), (0, operators_1.mergeMap)((action) => {
|
|
11
|
+
const newScheduleActions = [];
|
|
12
|
+
const accountType = (0, scheduleListHelper_1.getAccountsTypesForScheduleEpics)();
|
|
13
|
+
const { accountListState, classListState } = state$.value;
|
|
14
|
+
if (accountListState.byReportId[accountType.accountListKey]?.fetchState ===
|
|
15
|
+
'Not-Started') {
|
|
16
|
+
newScheduleActions.push((0, accountListReducer_1.fetchAccountList)(accountType.accountListKey, true, false, false, false, accountType.allowedAccountList));
|
|
17
|
+
}
|
|
18
|
+
if (classListState.fetchState === 'Not-Started') {
|
|
19
|
+
newScheduleActions.push((0, classListReducer_1.fetchClassList)());
|
|
20
|
+
}
|
|
21
|
+
// The account and class fetches above are idempotent (both guard on 'Not-Started'), so they
|
|
22
|
+
// can run on every open. Clearing what the user entered cannot, so it is opt-in.
|
|
23
|
+
if (action.payload.shouldResetEnteredData) {
|
|
24
|
+
newScheduleActions.push((0, jeSchedulesViewReducer_1.resetNewScheduleLocalData)({ scheduleType: action.payload.scheduleType }));
|
|
25
|
+
newScheduleActions.push((0, jeSchedulesViewReducer_1.clearSearchTransactionsForNewSchedule)());
|
|
26
|
+
}
|
|
27
|
+
return (0, rxjs_1.from)(newScheduleActions);
|
|
28
|
+
}));
|
|
29
|
+
exports.initializeNewScheduleEpic = initializeNewScheduleEpic;
|