@zeniai/client-epic-state 5.2.10 → 5.2.11
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/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/index.d.ts +2 -1
- 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/package.json +1 -1
|
@@ -95,7 +95,10 @@ const companyMonthEndReportView = createSlice({
|
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
saveCompanyMonthEndReport: {
|
|
98
|
-
|
|
98
|
+
// The trailing pair is an object, not two more positional optionals: both
|
|
99
|
+
// are optional and neither is a distinct type, so a swapped call would
|
|
100
|
+
// compile silently.
|
|
101
|
+
prepare(recipientEmailList, companyId, subject, isPreview, fileId, zeniRequestsHtml, options) {
|
|
99
102
|
return {
|
|
100
103
|
payload: {
|
|
101
104
|
recipientEmailList,
|
|
@@ -104,7 +107,8 @@ const companyMonthEndReportView = createSlice({
|
|
|
104
107
|
isPreview,
|
|
105
108
|
fileId,
|
|
106
109
|
zeniRequestsHtml,
|
|
107
|
-
tenantId,
|
|
110
|
+
tenantId: options?.tenantId,
|
|
111
|
+
agentInsightEdits: options?.agentInsightEdits,
|
|
108
112
|
},
|
|
109
113
|
};
|
|
110
114
|
},
|
|
@@ -18,6 +18,10 @@ export const toCompanyMonthEndReportData = (data) => {
|
|
|
18
18
|
: undefined,
|
|
19
19
|
draftUserId: data.draft_user_id,
|
|
20
20
|
zeniRequestsData: data.zeni_requests_data ?? [],
|
|
21
|
+
agentInsightsEditedBy: data.agent_insights_edited_by ?? undefined,
|
|
22
|
+
agentInsightsEditedAt: data.agent_insights_edited_at != null
|
|
23
|
+
? date(data.agent_insights_edited_at)
|
|
24
|
+
: undefined,
|
|
21
25
|
};
|
|
22
26
|
};
|
|
23
27
|
export function toMonthEndHistoricData(data) {
|
|
@@ -6,9 +6,10 @@ import { getAttachmentFileByFileId } from '../../../entity/file/fileSelector';
|
|
|
6
6
|
import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
7
7
|
import { createZeniAPIStatus, isSuccessStatus } from '../../../responsePayload';
|
|
8
8
|
import { dateNow, getBusinessDayOfDate } from '../../../zeniDayJS';
|
|
9
|
+
import { buildMonthEndTemplateData } from '../monthEndTemplateData';
|
|
9
10
|
import { saveCompanyMonthEndReport, updateCompanyMonthEndReportDataOnSaveSuccess, updateStatusForCompanyMonthEndReportOnSaveFailure, } from '../companyMonthEndReportViewReducer';
|
|
10
11
|
export const saveCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveCompanyMonthEndReport.match), mergeMap((action) => {
|
|
11
|
-
const { companyId, recipientEmailList, subject, isPreview, fileId, zeniRequestsHtml, tenantId, } = action.payload;
|
|
12
|
+
const { agentInsightEdits, companyId, recipientEmailList, subject, isPreview, fileId, zeniRequestsHtml, tenantId, } = action.payload;
|
|
12
13
|
const state = state$.value;
|
|
13
14
|
const company = state.companyState.companiesById[companyId];
|
|
14
15
|
const companyName = state.companyState.companiesById[companyId].companyInfo.name;
|
|
@@ -27,15 +28,18 @@ export const saveCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => acti
|
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
const payload = {
|
|
30
|
-
template_data:
|
|
31
|
-
...state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData,
|
|
32
|
-
subject,
|
|
33
|
-
},
|
|
31
|
+
template_data: buildMonthEndTemplateData(state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData, subject, agentInsightEdits),
|
|
34
32
|
recipient_email_list: recipientEmailList,
|
|
35
33
|
tenant_receiver_email_list: state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.tenantReceiverEmailList,
|
|
36
34
|
last_report_sent_business_day: lastReportSentBusinessDay,
|
|
37
35
|
last_report_sent_date: lastReportSentDate.format(DEFAULT_DATE_FORMAT),
|
|
38
|
-
|
|
36
|
+
// Three-way, because the server distinguishes all three: an empty string means the user
|
|
37
|
+
// cleared the box and is sent as an explicit null, a value is sent as-is, and undefined
|
|
38
|
+
// means this save was not about Zeni Requests at all — the key is omitted so the draft's
|
|
39
|
+
// existing text is left alone.
|
|
40
|
+
...(zeniRequestsHtml !== undefined && {
|
|
41
|
+
zeni_requests_html: zeniRequestsHtml === '' ? null : zeniRequestsHtml,
|
|
42
|
+
}),
|
|
39
43
|
files: filePayload,
|
|
40
44
|
};
|
|
41
45
|
const query = { is_preview: isPreview };
|
|
@@ -7,6 +7,7 @@ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
|
|
|
7
7
|
import { createZeniAPIStatus, isSuccessStatus } from '../../../responsePayload';
|
|
8
8
|
import { dateNow, getBusinessDayOfDate } from '../../../zeniDayJS';
|
|
9
9
|
import { updateMetaDataOnSendMonthEndReport } from '../../companyView/companyViewReducer';
|
|
10
|
+
import { buildMonthEndTemplateData } from '../monthEndTemplateData';
|
|
10
11
|
import { sendCompanyMonthEndReport, updateStatusForSendCompanyMonthEndReport, } from '../companyMonthEndReportViewReducer';
|
|
11
12
|
export const sendCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(sendCompanyMonthEndReport.match), mergeMap((action) => {
|
|
12
13
|
const { companyId, fileId, tenantId } = action.payload;
|
|
@@ -31,15 +32,18 @@ export const sendCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => acti
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
const payload = {
|
|
34
|
-
template_data:
|
|
35
|
-
...state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData,
|
|
36
|
-
subject,
|
|
37
|
-
},
|
|
35
|
+
template_data: buildMonthEndTemplateData(state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.templateData, subject),
|
|
38
36
|
recipient_email_list: recipientEmailList,
|
|
39
37
|
tenant_receiver_email_list: state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.tenantReceiverEmailList,
|
|
40
38
|
last_report_sent_business_day: lastReportSentBusinessDay,
|
|
41
39
|
last_report_sent_date: lastReportSentDate.format(DEFAULT_DATE_FORMAT),
|
|
42
|
-
|
|
40
|
+
// Three-way, because the server distinguishes all three: an empty string means the user
|
|
41
|
+
// cleared the box and is sent as an explicit null, a value is sent as-is, and undefined
|
|
42
|
+
// means this save was not about Zeni Requests at all — the key is omitted so the draft's
|
|
43
|
+
// existing text is left alone.
|
|
44
|
+
...(zeniRequestsHtml !== undefined && {
|
|
45
|
+
zeni_requests_html: zeniRequestsHtml === '' ? null : zeniRequestsHtml,
|
|
46
|
+
}),
|
|
43
47
|
files: filePayload,
|
|
44
48
|
};
|
|
45
49
|
return zeniAPI
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The AI CFO (V2) month-end email renders its subject line from this merge var
|
|
3
|
+
* rather than from the generic `subject` key, so a subject typed in the cockpit
|
|
4
|
+
* has to be written here too or the sent email keeps the AI's original subject.
|
|
5
|
+
*/
|
|
6
|
+
export const AGENT_INSIGHTS_SUBJECT_KEY = 'agent_insights_subject';
|
|
7
|
+
/**
|
|
8
|
+
* Build the `template_data` sent to the month-end email endpoint.
|
|
9
|
+
*
|
|
10
|
+
* Controller edits to the AI-generated insight fields are merged over the
|
|
11
|
+
* template data held in the store. The server sanitizes and persists whichever
|
|
12
|
+
* `agent_insights_*` keys are present, and the send path renders from the
|
|
13
|
+
* persisted draft — so only a save (`is_preview: false`) makes an edit stick.
|
|
14
|
+
*/
|
|
15
|
+
export const buildMonthEndTemplateData = (templateData, subject, agentInsightEdits) => {
|
|
16
|
+
const merged = {
|
|
17
|
+
...templateData,
|
|
18
|
+
...agentInsightEdits,
|
|
19
|
+
subject,
|
|
20
|
+
};
|
|
21
|
+
// Only for AI CFO drafts (the key is absent on legacy ones), never over an
|
|
22
|
+
// explicit edit to the field itself, and never with an empty value — on send
|
|
23
|
+
// the subject comes from store state and can be absent, which must not blank
|
|
24
|
+
// the AI's subject line.
|
|
25
|
+
if (AGENT_INSIGHTS_SUBJECT_KEY in merged &&
|
|
26
|
+
agentInsightEdits?.[AGENT_INSIGHTS_SUBJECT_KEY] == null &&
|
|
27
|
+
subject != null &&
|
|
28
|
+
subject !== '') {
|
|
29
|
+
merged[AGENT_INSIGHTS_SUBJECT_KEY] = subject;
|
|
30
|
+
}
|
|
31
|
+
return merged;
|
|
32
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -267,6 +267,7 @@ import { CompanyHealthMetricsLocalData, CompanyHealthViewUIState } from './view/
|
|
|
267
267
|
import { fetchCompanyHealthMetricView, initializeCompanyHealthMetricViewLocalData, removeSelectedCompanyId, saveCompanyHealthMetricById, updateLocalStore as updateCompanyHealthMetricLocalStore, updateCompanyHealthMetricViewErrorStatus, updateCompanyHealthMetricViewSuccessStatus, updateCompanyHealthViewUIState } from './view/companyHealthMetricView/companyHealthMetricViewReducer';
|
|
268
268
|
import { CompanyDetailWithHealthMetric, CompanyHealthMetricDropDownOption, CompanyHealthMetricViewSelector, ProductServiceKey, ProductServices, companyHealthMetricDropDownOptions, getCompanyHealthMetricView, hasCompanyHealthMetricFormFieldChanged, isCompanyRunwayInfinite } from './view/companyHealthMetricView/companyHealthMetricViewSelector';
|
|
269
269
|
import { fetchCompanyMonthEndReportHistoricData, fetchCompanyMonthEndReportHistoricDates, fetchCompanyMonthEndReportTemplates, fetchCompanyMonthEndReportView, fetchImproveUsingZeniGPT, resetCompanyMonthEndReportFetchStatus, resetSendCompanyMonthEndReportFetchStatus, saveCompanyMonthEndReport, sendCompanyMonthEndReport } from './view/companyMonthEndReportView/companyMonthEndReportViewReducer';
|
|
270
|
+
import { AgentInsightEdits, MonthEndTemplateData } from './view/companyMonthEndReportView/companyMonthEndReportViewPayload';
|
|
270
271
|
import { CompanyMonthEndReportHistoricDataSelectorView, CompanyMonthEndReportSelectorView, getCompanyMonthEndReportHistoricData, getCompanyMonthEndReportSelectorView } from './view/companyMonthEndReportView/companyMonthEndReportViewSelector';
|
|
271
272
|
import { AuditSummaryData, CompanyMonthEndReportData, CompanyMonthReportTemplates, TemplatesList } from './view/companyMonthEndReportView/companyMonthEndReportViewState';
|
|
272
273
|
import { fetchCockpitContext, fetchCompanyTaskManagerView, fetchTaskManagerMetrics, updateCompanyTaskManagerViewFilters } from './view/companyTaskManagerView/companyTaskManagerViewReducer';
|
|
@@ -830,7 +831,7 @@ export { companyManagementSaveUpdates, fetchAllCockpitViews, fetchCompanyManagem
|
|
|
830
831
|
export { fetchReviewCompanyView, updateReviewCompanyListUIState, ReviewCompanyListUIState, ReviewCompanyView, ReviewCompanyColumnKey, ReviewTransactionsType, ReviewCompanySelectorView, getReviewCompanySelectorView, getReviewCompanyListCount, toReviewColumnKeyType, retryBankAccountConnection, AuditSummary, getAuditWarningsCount, };
|
|
831
832
|
export { CompanyPortfolioView, getCompanyPortfolioView, isInfiniteRunway };
|
|
832
833
|
export { AllCockpitTabsView, getAllCockpitTabsFilterView };
|
|
833
|
-
export { AuditSummaryData, fetchImproveUsingZeniGPT, fetchCompanyMonthEndReportView, sendCompanyMonthEndReport, saveCompanyMonthEndReport, resetCompanyMonthEndReportFetchStatus, resetSendCompanyMonthEndReportFetchStatus, getCompanyMonthEndReportSelectorView, CompanyMonthEndReportSelectorView, fetchCompanyMonthEndReportHistoricDates, fetchCompanyMonthEndReportHistoricData, fetchCompanyMonthEndReportTemplates, getCompanyMonthEndReportHistoricData, CompanyMonthEndReportHistoricDataSelectorView, CompanyMonthEndReportData, TemplatesList, CompanyMonthReportTemplates, };
|
|
834
|
+
export { AuditSummaryData, fetchImproveUsingZeniGPT, fetchCompanyMonthEndReportView, sendCompanyMonthEndReport, saveCompanyMonthEndReport, resetCompanyMonthEndReportFetchStatus, resetSendCompanyMonthEndReportFetchStatus, getCompanyMonthEndReportSelectorView, CompanyMonthEndReportSelectorView, AgentInsightEdits, MonthEndTemplateData, fetchCompanyMonthEndReportHistoricDates, fetchCompanyMonthEndReportHistoricData, fetchCompanyMonthEndReportTemplates, getCompanyMonthEndReportHistoricData, CompanyMonthEndReportHistoricDataSelectorView, CompanyMonthEndReportData, TemplatesList, CompanyMonthReportTemplates, };
|
|
834
835
|
export { Runway, AccountingSummary };
|
|
835
836
|
export { newAddressInLocalStore, getAddress, getNewAddress, getAllNewAddresses, getFormattedAddress, fetchAddress, AddressType, NewAddressData, AddressUpdatableInfo, createAddress, removeNewAddressDataInLocalStore, };
|
|
836
837
|
export { CockpitFilterCategory, CockpitFilters, DownloadCockpitTabOptions, FilterCombinationsByTabs, HealthViewSortKey, ManagementViewFilterCategoryField, ManagementViewSortKey, OnboardingViewSortKey, PortfolioViewFilterCategoryField, HealthMonitorViewFilterCategoryField, TaskManagerViewFilterCategoryField, PortfolioViewSortKey, SubscriptionViewFilterCategoryField, toManagementSortKeyType, toOnboardingSortKeyType, toPortfolioSortKeyType, toHealthSortKeyType, TaskGroupScope, TaskManagerViewSortKey, toTaskManagerSortKeyType, updateCompanyTaskManagerViewFilters, };
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.11",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|