@zeniai/client-epic-state 4.9.8 → 4.9.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.
Files changed (56) hide show
  1. package/lib/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.d.ts +1 -0
  2. package/lib/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.js +2 -1
  3. package/lib/entity/company/companyHelper.d.ts +5 -0
  4. package/lib/entity/company/companyHelper.js +24 -0
  5. package/lib/entity/company/companySelector.d.ts +7 -0
  6. package/lib/entity/company/companySelector.js +17 -1
  7. package/lib/entity/userRole/userRoleType.d.ts +8 -1
  8. package/lib/entity/userRole/userRoleType.js +73 -2
  9. package/lib/epic.d.ts +8 -6
  10. package/lib/epic.js +8 -6
  11. package/lib/index.d.ts +17 -17
  12. package/lib/index.js +41 -21
  13. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewPayload.d.ts +16 -0
  14. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.d.ts +21 -1
  15. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +77 -3
  16. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewSelector.d.ts +11 -1
  17. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewSelector.js +44 -1
  18. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.d.ts +15 -3
  19. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.js +23 -1
  20. package/lib/view/companyMonthEndReportView/epics/fetchCompanyMonthEndReportHistoricDataEpic.d.ts +8 -0
  21. package/lib/view/companyMonthEndReportView/epics/fetchCompanyMonthEndReportHistoricDataEpic.js +67 -0
  22. package/lib/view/companyMonthEndReportView/epics/fetchCompanyMonthEndReportHistoricDatesEpic.d.ts +7 -0
  23. package/lib/view/companyMonthEndReportView/epics/fetchCompanyMonthEndReportHistoricDatesEpic.js +54 -0
  24. package/lib/view/companyMonthEndReportView/{fetchCompanyMonthEndReportViewEpic.d.ts → epics/fetchCompanyMonthEndReportViewEpic.d.ts} +4 -4
  25. package/lib/view/companyMonthEndReportView/{fetchCompanyMonthEndReportViewEpic.js → epics/fetchCompanyMonthEndReportViewEpic.js} +4 -2
  26. package/lib/view/companyMonthEndReportView/{improveUsingZeniGPTEpic.d.ts → epics/improveUsingZeniGPTEpic.d.ts} +3 -3
  27. package/lib/view/companyMonthEndReportView/{improveUsingZeniGPTEpic.js → epics/improveUsingZeniGPTEpic.js} +2 -2
  28. package/lib/view/companyMonthEndReportView/{saveCompanyMonthEndReportEpic.d.ts → epics/saveCompanyMonthEndReportEpic.d.ts} +5 -5
  29. package/lib/view/companyMonthEndReportView/{saveCompanyMonthEndReportEpic.js → epics/saveCompanyMonthEndReportEpic.js} +9 -7
  30. package/lib/view/companyMonthEndReportView/{sendCompanyMonthEndReportEpic.d.ts → epics/sendCompanyMonthEndReportEpic.d.ts} +5 -5
  31. package/lib/view/companyMonthEndReportView/{sendCompanyMonthEndReportEpic.js → epics/sendCompanyMonthEndReportEpic.js} +9 -7
  32. package/lib/view/recommendation/fetchEntityRecommendationsByTransactionIdEpic.d.ts +10 -0
  33. package/lib/view/recommendation/{fetchRecommendationByEntityQboIdEpic.js → fetchEntityRecommendationsByTransactionIdEpic.js} +13 -6
  34. package/lib/view/recommendation/fetchRecommendationByEntityIdEpic.js +2 -2
  35. package/lib/view/recommendation/recommendationHelper.d.ts +3 -0
  36. package/lib/view/recommendation/recommendationHelper.js +37 -21
  37. package/lib/view/recommendation/recommendationReducer.d.ts +1 -1
  38. package/lib/view/recommendation/recommendationReducer.js +3 -3
  39. package/lib/view/settingsView/settingsViewHelpers.d.ts +10 -0
  40. package/lib/view/settingsView/settingsViewHelpers.js +111 -1
  41. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.d.ts +1 -0
  42. package/lib/view/spendManagement/reimbursement/editRemiView/editRemiViewSelector.js +17 -13
  43. package/lib/view/spendManagement/reimbursement/reimbursementConfig/reimbursementConfigState.d.ts +1 -0
  44. package/lib/view/spendManagement/reimbursement/reimbursementConfig/reimbursementConfigState.js +2 -1
  45. package/lib/view/spendManagement/reimbursement/remiDetailView/epics/fetchRemiDetailEpic.d.ts +2 -1
  46. package/lib/view/spendManagement/reimbursement/remiDetailView/epics/fetchRemiDetailEpic.js +8 -2
  47. package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.d.ts +2 -1
  48. package/lib/view/spendManagement/reimbursement/remiDetailView/remiDetailViewSelector.js +23 -14
  49. package/lib/view/transactionDetail/transactionDetailLocalDataHelper.d.ts +2 -1
  50. package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +3 -2
  51. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +3 -3
  52. package/lib/view/transactionDetail/transactionDetailReducer.js +4 -4
  53. package/lib/view/transactionDetail/transactionDetailState.d.ts +7 -0
  54. package/lib/view/transactionDetail/transactionDetailState.js +4 -3
  55. package/package.json +1 -1
  56. package/lib/view/recommendation/fetchRecommendationByEntityQboIdEpic.d.ts +0 -10
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toCompanyMonthEndReportData = void 0;
3
+ exports.toMonthEndHistoricData = exports.toCompanyMonthEndReportData = exports.getMonthEndReportHistoricDataKey = void 0;
4
+ const formatZeniDateFY_1 = require("../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
4
5
  const fileReducer_1 = require("../../entity/file/fileReducer");
5
6
  const zeniDayJS_1 = require("../../zeniDayJS");
7
+ const getMonthEndReportHistoricDataKey = (companyId, reportDate) => `${companyId}_${reportDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)}`;
8
+ exports.getMonthEndReportHistoricDataKey = getMonthEndReportHistoricDataKey;
6
9
  const toCompanyMonthEndReportData = (data) => {
7
10
  var _a, _b;
8
11
  return {
@@ -22,3 +25,22 @@ const toCompanyMonthEndReportData = (data) => {
22
25
  };
23
26
  };
24
27
  exports.toCompanyMonthEndReportData = toCompanyMonthEndReportData;
28
+ function toMonthEndHistoricData(data) {
29
+ const { history: historicData } = data;
30
+ if (historicData.length === 0) {
31
+ return {
32
+ recipientEmailList: [],
33
+ };
34
+ }
35
+ return {
36
+ recipientEmailList: historicData[0].recipient_email_list,
37
+ concatenatedHtml: historicData[0].email_history_html,
38
+ reportSentDate: (0, zeniDayJS_1.date)(historicData[0].month_end_email_send_date),
39
+ subject: historicData[0].subject,
40
+ draftUserId: historicData[0].user_id,
41
+ attachmentFile: historicData[0].files != null && historicData[0].files.length > 0
42
+ ? (0, fileReducer_1.mapAttachmentFilePayloadToFile)(historicData[0].files[0])
43
+ : undefined,
44
+ };
45
+ }
46
+ exports.toMonthEndHistoricData = toMonthEndHistoricData;
@@ -0,0 +1,8 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ActionsObservable, StateObservable } from 'redux-observable';
3
+ import { ZeniAPI } from '../../../zeniAPI';
4
+ import { RootState } from '../../../reducer';
5
+ import { fetchCompanyMonthEndReportHistoricData, updateCompanyMonthEndReportHistoricDataOnSuccess, updateCompanyMonthEndReportHistoricDataOnFailure } from '../companyMonthEndReportViewReducer';
6
+ import { updateAttachmentFiles } from '../../../entity/file/fileReducer';
7
+ export declare type ActionType = ReturnType<typeof fetchCompanyMonthEndReportHistoricData> | ReturnType<typeof updateCompanyMonthEndReportHistoricDataOnSuccess> | ReturnType<typeof updateCompanyMonthEndReportHistoricDataOnFailure> | ReturnType<typeof updateAttachmentFiles>;
8
+ export declare const fetchCompanyMonthEndReportHistoricDataEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchCompanyMonthEndReportHistoricDataEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../responsePayload");
7
+ const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
8
+ const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
9
+ const fileReducer_1 = require("../../../entity/file/fileReducer");
10
+ const fetchCompanyMonthEndReportHistoricDataEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.fetchCompanyMonthEndReportHistoricData.match), (0, operators_1.switchMap)((action) => {
11
+ const { companyId, reportSentDate } = action.payload;
12
+ const state = state$.value;
13
+ const tenantId = state.companyState.companiesById[companyId].companyInfo.tenantId;
14
+ const queryParam = {
15
+ history: true,
16
+ month_year: reportSentDate.format(formatZeniDateFY_1.FULL_MONTH_FULL_YEAR_FORMAT),
17
+ };
18
+ if (tenantId != null) {
19
+ return zeniAPI
20
+ .getJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}/emails/month-end?query=${encodeURIComponent(JSON.stringify(queryParam))}`, {
21
+ 'zeni-tenant-id': tenantId,
22
+ })
23
+ .pipe((0, operators_1.mergeMap)((response) => {
24
+ var _a;
25
+ if ((0, responsePayload_1.isSuccessResponse)(response) &&
26
+ ((_a = response.data) === null || _a === void 0 ? void 0 : _a.history) != null) {
27
+ const actions = [
28
+ (0, companyMonthEndReportViewReducer_1.updateCompanyMonthEndReportHistoricDataOnSuccess)({
29
+ companyId,
30
+ reportSentDate,
31
+ data: response.data,
32
+ }),
33
+ ];
34
+ if (response.data.history.length > 0) {
35
+ actions.push((0, fileReducer_1.updateAttachmentFiles)({
36
+ files: response.data.history[0].files,
37
+ }));
38
+ }
39
+ return (0, rxjs_1.from)(actions);
40
+ }
41
+ else {
42
+ const actions = [
43
+ (0, companyMonthEndReportViewReducer_1.updateCompanyMonthEndReportHistoricDataOnFailure)({
44
+ companyId,
45
+ reportSentDate,
46
+ error: response.status,
47
+ }),
48
+ ];
49
+ return (0, rxjs_1.from)(actions);
50
+ }
51
+ }), (0, operators_1.catchError)((error) => {
52
+ const actions = [
53
+ (0, companyMonthEndReportViewReducer_1.updateCompanyMonthEndReportHistoricDataOnFailure)({
54
+ companyId,
55
+ reportSentDate,
56
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'Company Month End Report Historic Data errored out' +
57
+ JSON.stringify(error)),
58
+ }),
59
+ ];
60
+ return (0, rxjs_1.from)(actions);
61
+ }));
62
+ }
63
+ else {
64
+ return (0, rxjs_1.from)([]);
65
+ }
66
+ }));
67
+ exports.fetchCompanyMonthEndReportHistoricDataEpic = fetchCompanyMonthEndReportHistoricDataEpic;
@@ -0,0 +1,7 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ActionsObservable, StateObservable } from 'redux-observable';
3
+ import { ZeniAPI } from '../../../zeniAPI';
4
+ import { RootState } from '../../../reducer';
5
+ import { fetchCompanyMonthEndReportHistoricDates, updateCompanyMonthEndReportHistoricDatesOnSuccess, updateCompanyMonthEndReportHistoricDatesOnFailure } from '../companyMonthEndReportViewReducer';
6
+ export declare type ActionType = ReturnType<typeof fetchCompanyMonthEndReportHistoricDates> | ReturnType<typeof updateCompanyMonthEndReportHistoricDatesOnSuccess> | ReturnType<typeof updateCompanyMonthEndReportHistoricDatesOnFailure>;
7
+ export declare const fetchCompanyMonthEndReportHistoricDatesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchCompanyMonthEndReportHistoricDatesEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../responsePayload");
7
+ const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
8
+ const fetchCompanyMonthEndReportHistoricDatesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.fetchCompanyMonthEndReportHistoricDates.match), (0, operators_1.switchMap)((action) => {
9
+ const { companyId } = action.payload;
10
+ const state = state$.value;
11
+ const tenantId = state.companyState.companiesById[companyId].companyInfo.tenantId;
12
+ const queryParam = {
13
+ history_dates: true,
14
+ };
15
+ if (tenantId != null) {
16
+ return zeniAPI
17
+ .getJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}/emails/month-end?query=${encodeURIComponent(JSON.stringify(queryParam))}`, {
18
+ 'zeni-tenant-id': tenantId,
19
+ })
20
+ .pipe((0, operators_1.mergeMap)((response) => {
21
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
22
+ const actions = [
23
+ (0, companyMonthEndReportViewReducer_1.updateCompanyMonthEndReportHistoricDatesOnSuccess)({
24
+ companyId,
25
+ data: response.data,
26
+ }),
27
+ ];
28
+ return (0, rxjs_1.from)(actions);
29
+ }
30
+ else {
31
+ const actions = [
32
+ (0, companyMonthEndReportViewReducer_1.updateCompanyMonthEndReportHistoricDatesOnFailure)({
33
+ companyId,
34
+ error: response.status,
35
+ }),
36
+ ];
37
+ return (0, rxjs_1.from)(actions);
38
+ }
39
+ }), (0, operators_1.catchError)((error) => {
40
+ const actions = [
41
+ (0, companyMonthEndReportViewReducer_1.updateCompanyMonthEndReportHistoricDatesOnFailure)({
42
+ companyId,
43
+ error: (0, responsePayload_1.createZeniAPIStatus)('Unexpected error', 'Company Month End Report Historic Dates errored out' +
44
+ JSON.stringify(error)),
45
+ }),
46
+ ];
47
+ return (0, rxjs_1.from)(actions);
48
+ }));
49
+ }
50
+ else {
51
+ return (0, rxjs_1.from)([]);
52
+ }
53
+ }));
54
+ exports.fetchCompanyMonthEndReportHistoricDatesEpic = fetchCompanyMonthEndReportHistoricDatesEpic;
@@ -1,8 +1,8 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { ActionsObservable, StateObservable } from 'redux-observable';
3
- import { ZeniAPI } from '../../zeniAPI';
4
- import { RootState } from '../../reducer';
5
- import { fetchCompanyMonthEndReportView, updateCompanyMonthEndReportViewOnFailure, updateCompanyMonthEndReportViewOnSuccess } from './companyMonthEndReportViewReducer';
6
- import { updateAttachmentFiles } from '../../entity/file/fileReducer';
3
+ import { ZeniAPI } from '../../../zeniAPI';
4
+ import { RootState } from '../../../reducer';
5
+ import { fetchCompanyMonthEndReportView, updateCompanyMonthEndReportViewOnFailure, updateCompanyMonthEndReportViewOnSuccess } from '../companyMonthEndReportViewReducer';
6
+ import { updateAttachmentFiles } from '../../../entity/file/fileReducer';
7
7
  export declare type ActionType = ReturnType<typeof fetchCompanyMonthEndReportView> | ReturnType<typeof updateCompanyMonthEndReportViewOnSuccess> | ReturnType<typeof updateCompanyMonthEndReportViewOnFailure> | ReturnType<typeof updateAttachmentFiles>;
8
8
  export declare const fetchCompanyMonthEndReportViewEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchCompanyMonthEndReportViewEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../responsePayload");
7
- const companyMonthEndReportViewReducer_1 = require("./companyMonthEndReportViewReducer");
6
+ const responsePayload_1 = require("../../../responsePayload");
7
+ const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
8
+ const fileReducer_1 = require("../../../entity/file/fileReducer");
8
9
  const fetchCompanyMonthEndReportViewEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.fetchCompanyMonthEndReportView.match), (0, operators_1.switchMap)((action) => {
9
10
  const { cacheOverride, companyId } = action.payload;
10
11
  const state = state$.value;
@@ -20,6 +21,7 @@ const fetchCompanyMonthEndReportViewEpic = (actions$, state$, zeniAPI) => action
20
21
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
21
22
  const actions = [
22
23
  (0, companyMonthEndReportViewReducer_1.updateCompanyMonthEndReportViewOnSuccess)(companyId, response.data),
24
+ (0, fileReducer_1.updateAttachmentFiles)({ files: response.data.files }),
23
25
  ];
24
26
  return (0, rxjs_1.from)(actions);
25
27
  }
@@ -1,7 +1,7 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
- import { RootState } from '../../reducer';
4
- import { ZeniAPI } from '../../zeniAPI';
5
- import { fetchImproveUsingZeniGPT, updateImproveUsingZeniGPTSuccess, updateImproveUsingZeniGPTFailure } from './companyMonthEndReportViewReducer';
3
+ import { RootState } from '../../../reducer';
4
+ import { ZeniAPI } from '../../../zeniAPI';
5
+ import { fetchImproveUsingZeniGPT, updateImproveUsingZeniGPTSuccess, updateImproveUsingZeniGPTFailure } from '../companyMonthEndReportViewReducer';
6
6
  export declare type ActionType = ReturnType<typeof fetchImproveUsingZeniGPT> | ReturnType<typeof updateImproveUsingZeniGPTSuccess> | ReturnType<typeof updateImproveUsingZeniGPTFailure>;
7
7
  export declare const improveUsingZeniGPTEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.improveUsingZeniGPTEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- const companyMonthEndReportViewReducer_1 = require("./companyMonthEndReportViewReducer");
7
- const responsePayload_1 = require("../../responsePayload");
6
+ const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
7
+ const responsePayload_1 = require("../../../responsePayload");
8
8
  const improveUsingZeniGPTEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.fetchImproveUsingZeniGPT.match), (0, operators_1.switchMap)((action) => {
9
9
  const { companyId } = action.payload;
10
10
  const state = state$.value;
@@ -1,9 +1,9 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
- import { RootState } from '../../reducer';
4
- import { ZeniAPI } from '../../zeniAPI';
5
- import { saveCompanyMonthEndReport, updateCompanyMonthEndReportDataOnSaveSuccess, updateStatusForCompanyMonthEndReportOnSaveFailure } from './companyMonthEndReportViewReducer';
6
- import { openSnackbar } from '../../entity/snackbar/snackbarReducer';
7
- import { toggleCompanyMonthEndReportDraftFlag } from '../../entity/company/companyReducer';
3
+ import { RootState } from '../../../reducer';
4
+ import { ZeniAPI } from '../../../zeniAPI';
5
+ import { saveCompanyMonthEndReport, updateCompanyMonthEndReportDataOnSaveSuccess, updateStatusForCompanyMonthEndReportOnSaveFailure } from '../companyMonthEndReportViewReducer';
6
+ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
7
+ import { toggleCompanyMonthEndReportDraftFlag } from '../../../entity/company/companyReducer';
8
8
  export declare type ActionType = ReturnType<typeof saveCompanyMonthEndReport> | ReturnType<typeof updateStatusForCompanyMonthEndReportOnSaveFailure> | ReturnType<typeof toggleCompanyMonthEndReportDraftFlag> | ReturnType<typeof openSnackbar> | ReturnType<typeof updateCompanyMonthEndReportDataOnSaveSuccess>;
9
9
  export declare const saveCompanyMonthEndReportEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.saveCompanyMonthEndReportEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- const companyMonthEndReportViewReducer_1 = require("./companyMonthEndReportViewReducer");
7
- const responsePayload_1 = require("../../responsePayload");
8
- const zeniDayJS_1 = require("../../zeniDayJS");
9
- const snackbarReducer_1 = require("../../entity/snackbar/snackbarReducer");
10
- const companyReducer_1 = require("../../entity/company/companyReducer");
11
- const fileSelector_1 = require("../../entity/file/fileSelector");
6
+ const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
7
+ const responsePayload_1 = require("../../../responsePayload");
8
+ const zeniDayJS_1 = require("../../../zeniDayJS");
9
+ const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
10
+ const companyReducer_1 = require("../../../entity/company/companyReducer");
11
+ const fileSelector_1 = require("../../../entity/file/fileSelector");
12
+ const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
12
13
  const saveCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.saveCompanyMonthEndReport.match), (0, operators_1.mergeMap)((action) => {
13
14
  const { companyId, recipientEmailList, subject, isPreview, fileId, zeniRequestsHtml, } = action.payload;
14
15
  const state = state$.value;
@@ -33,8 +34,9 @@ const saveCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pi
33
34
  recipient_email_list: recipientEmailList,
34
35
  tenant_receiver_email_list: state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.tenantReceiverEmailList,
35
36
  last_report_sent_business_day: lastReportSentBusinessDay,
36
- last_report_sent_date: lastReportSentDate.format('YYYY-MM-DD'),
37
+ last_report_sent_date: lastReportSentDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
37
38
  zeni_requests_html: zeniRequestsHtml,
39
+ files: filePayload,
38
40
  };
39
41
  const query = { is_preview: isPreview };
40
42
  return zeniAPI
@@ -1,9 +1,9 @@
1
1
  import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
- import { RootState } from '../../reducer';
4
- import { ZeniAPI } from '../../zeniAPI';
5
- import { sendCompanyMonthEndReport, updateStatusForSendCompanyMonthEndReport } from './companyMonthEndReportViewReducer';
6
- import { toggleCompanyMonthEndReportDraftFlag, updateCompanyMonthEndReportSentDate } from '../../entity/company/companyReducer';
7
- import { openSnackbar } from '../../entity/snackbar/snackbarReducer';
3
+ import { RootState } from '../../../reducer';
4
+ import { ZeniAPI } from '../../../zeniAPI';
5
+ import { sendCompanyMonthEndReport, updateStatusForSendCompanyMonthEndReport } from '../companyMonthEndReportViewReducer';
6
+ import { toggleCompanyMonthEndReportDraftFlag, updateCompanyMonthEndReportSentDate } from '../../../entity/company/companyReducer';
7
+ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
8
8
  export declare type ActionType = ReturnType<typeof sendCompanyMonthEndReport> | ReturnType<typeof updateCompanyMonthEndReportSentDate> | ReturnType<typeof updateStatusForSendCompanyMonthEndReport> | ReturnType<typeof toggleCompanyMonthEndReportDraftFlag> | ReturnType<typeof openSnackbar>;
9
9
  export declare const sendCompanyMonthEndReportEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sendCompanyMonthEndReportEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- const companyMonthEndReportViewReducer_1 = require("./companyMonthEndReportViewReducer");
7
- const responsePayload_1 = require("../../responsePayload");
8
- const zeniDayJS_1 = require("../../zeniDayJS");
9
- const companyReducer_1 = require("../../entity/company/companyReducer");
10
- const snackbarReducer_1 = require("../../entity/snackbar/snackbarReducer");
11
- const fileSelector_1 = require("../../entity/file/fileSelector");
6
+ const companyMonthEndReportViewReducer_1 = require("../companyMonthEndReportViewReducer");
7
+ const responsePayload_1 = require("../../../responsePayload");
8
+ const zeniDayJS_1 = require("../../../zeniDayJS");
9
+ const companyReducer_1 = require("../../../entity/company/companyReducer");
10
+ const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
11
+ const fileSelector_1 = require("../../../entity/file/fileSelector");
12
+ const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
12
13
  const sendCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(companyMonthEndReportViewReducer_1.sendCompanyMonthEndReport.match), (0, operators_1.mergeMap)((action) => {
13
14
  const { companyId, fileId } = action.payload;
14
15
  const state = state$.value;
@@ -36,8 +37,9 @@ const sendCompanyMonthEndReportEpic = (actions$, state$, zeniAPI) => actions$.pi
36
37
  recipient_email_list: recipientEmailList,
37
38
  tenant_receiver_email_list: state.companyMonthEndReportViewState.monthEndReportDataByCompanyId[companyId].companyMonthEndReportData.tenantReceiverEmailList,
38
39
  last_report_sent_business_day: lastReportSentBusinessDay,
39
- last_report_sent_date: lastReportSentDate.format('YYYY-MM-DD'),
40
+ last_report_sent_date: lastReportSentDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
40
41
  zeni_requests_html: zeniRequestsHtml,
42
+ files: filePayload,
41
43
  };
42
44
  return zeniAPI
43
45
  .postAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}/emails/month-end`, payload, {
@@ -0,0 +1,10 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../reducer';
4
+ import { ZeniAPI } from '../../zeniAPI';
5
+ import { EntityType } from '../../entity/genericEntity/entity';
6
+ import { fetchEntityRecommendationsByTransactionId, updateRecommendationForEntity, updateRecommendationForEntityFailure } from './recommendationReducer';
7
+ import { setEntityRecommendationForLineIdsForTransactionDetail } from '../transactionDetail/transactionDetailReducer';
8
+ export declare type ActionType = ReturnType<typeof updateRecommendationForEntity> | ReturnType<typeof fetchEntityRecommendationsByTransactionId> | ReturnType<typeof updateRecommendationForEntityFailure> | ReturnType<typeof setEntityRecommendationForLineIdsForTransactionDetail>;
9
+ export declare const fetchEntityRecommendationsByTransactionIdEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
10
+ export declare const toEntityTypeURL: (entityType: EntityType) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toEntityTypeURL = exports.fetchRecommendationByEntityQboIdEpic = void 0;
3
+ exports.toEntityTypeURL = exports.fetchEntityRecommendationsByTransactionIdEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const responsePayload_1 = require("../../responsePayload");
@@ -8,23 +8,30 @@ const recommendationReducer_1 = require("./recommendationReducer");
8
8
  const transactionDetailReducer_1 = require("../transactionDetail/transactionDetailReducer");
9
9
  const recommendationHelper_1 = require("./recommendationHelper");
10
10
  const accountListSelector_1 = require("../accountList/accountListSelector");
11
- const fetchRecommendationByEntityQboIdEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.fetchRecommendationByEntityQboId.match), (0, operators_1.switchMap)((action) => {
11
+ const transactionDetailState_1 = require("../transactionDetail/transactionDetailState");
12
+ const fetchEntityRecommendationsByTransactionIdEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.fetchEntityRecommendationsByTransactionId.match), (0, operators_1.switchMap)((action) => {
12
13
  const { entity, amount, transactionDetails } = action.payload;
14
+ const query = {
15
+ amount,
16
+ transaction_id: (0, transactionDetailState_1.getActualTransactionID)(transactionDetails.transactionId.id),
17
+ transaction_type: transactionDetails.transaction.type,
18
+ };
13
19
  return zeniAPI
14
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${(0, exports.toEntityTypeURL)(entity.type)}/${entity.qboId}/recommendations?query=${encodeURIComponent(`{"amount":${amount}}`)}`)
20
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${(0, exports.toEntityTypeURL)(entity.type)}/${entity.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(query))}`)
15
21
  .pipe((0, operators_1.mergeMap)((response) => {
16
22
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
17
23
  const actions = [];
18
24
  const { transactionId, transaction, lineIds } = transactionDetails;
25
+ const recommendationByLineId = (0, recommendationHelper_1.getRecommendationByLineIdFromRecommendationPayload)(response.data.recommendations, lineIds);
19
26
  const recommendations = (0, recommendationHelper_1.getRecommendationFromRecommendationPayload)(response.data.recommendations);
20
27
  actions.push((0, recommendationReducer_1.updateRecommendationForEntity)({
21
28
  entityId: entity.id,
22
29
  entityType: entity.type,
23
30
  recommendations,
24
31
  }));
25
- if (recommendations != null) {
32
+ if (recommendationByLineId != null) {
26
33
  const uncategorizedIncomeExpense = (0, accountListSelector_1.getUncategorizedAccounts)(state$.value.accountState, state$.value.accountListState, 'accountList');
27
- actions.push((0, transactionDetailReducer_1.setEntityRecommendationForLineIdsForTransactionDetail)(transactionId, transaction, lineIds, entity, amount, recommendations, uncategorizedIncomeExpense));
34
+ actions.push((0, transactionDetailReducer_1.setEntityRecommendationForLineIdsForTransactionDetail)(transactionId, transaction, lineIds, entity, amount, recommendationByLineId, uncategorizedIncomeExpense));
28
35
  }
29
36
  return (0, rxjs_1.from)(actions);
30
37
  }
@@ -42,7 +49,7 @@ const fetchRecommendationByEntityQboIdEpic = (actions$, state$, zeniAPI) => acti
42
49
  JSON.stringify(error)),
43
50
  }))));
44
51
  }));
45
- exports.fetchRecommendationByEntityQboIdEpic = fetchRecommendationByEntityQboIdEpic;
52
+ exports.fetchEntityRecommendationsByTransactionIdEpic = fetchEntityRecommendationsByTransactionIdEpic;
46
53
  const toEntityTypeURL = (entityType) => {
47
54
  return `${entityType}s`;
48
55
  };
@@ -6,11 +6,11 @@ const operators_1 = require("rxjs/operators");
6
6
  const responsePayload_1 = require("../../responsePayload");
7
7
  const recommendationReducer_1 = require("./recommendationReducer");
8
8
  const recommendationHelper_1 = require("./recommendationHelper");
9
- const fetchRecommendationByEntityQboIdEpic_1 = require("./fetchRecommendationByEntityQboIdEpic");
9
+ const fetchEntityRecommendationsByTransactionIdEpic_1 = require("./fetchEntityRecommendationsByTransactionIdEpic");
10
10
  const fetchRecommendationByEntityIdEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.fetchRecommendationByEntityId.match), (0, operators_1.mergeMap)((action) => {
11
11
  const { entityId, entityType } = action.payload;
12
12
  return zeniAPI
13
- .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${(0, fetchRecommendationByEntityQboIdEpic_1.toEntityTypeURL)(entityType)}/${entityId}/recommendations`)
13
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${(0, fetchEntityRecommendationsByTransactionIdEpic_1.toEntityTypeURL)(entityType)}/${entityId}/recommendations`)
14
14
  .pipe((0, operators_1.mergeMap)((response) => {
15
15
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
16
16
  const actions = [];
@@ -1,3 +1,6 @@
1
1
  import { RecommendationPayload } from '../../commonPayloadTypes/recommendationPayload';
2
+ import { ID } from '../../commonStateTypes/common';
2
3
  import { Recommendation } from '../../commonStateTypes/recommendationBase';
4
+ import { RecommendationByLineId } from '../../entity/transaction/stateTypes/transaction';
3
5
  export declare const getRecommendationFromRecommendationPayload: (payload: RecommendationPayload[]) => Recommendation[] | undefined;
6
+ export declare const getRecommendationByLineIdFromRecommendationPayload: (recommendationPayload: RecommendationPayload[], lineIds: ID[]) => RecommendationByLineId | undefined;
@@ -1,35 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRecommendationFromRecommendationPayload = void 0;
3
+ exports.getRecommendationByLineIdFromRecommendationPayload = exports.getRecommendationFromRecommendationPayload = void 0;
4
4
  const accountPayload_1 = require("../../entity/account/accountPayload");
5
5
  const classPayload_1 = require("../../entity/class/classPayload");
6
+ const transactionPayload_1 = require("../../entity/transaction/payloadTypes/transactionPayload");
6
7
  const getRecommendationFromRecommendationPayload = (payload) => {
7
- var _a, _b;
8
8
  if (payload == null || payload.length === 0) {
9
9
  return undefined;
10
10
  }
11
- const recommendation = payload[0]; // In this case, there will be only one recommendation item since this is an entity recommendation.
12
- const accounts = recommendation.accounts;
13
- const classObjs = recommendation.accounting_classes;
14
11
  const recommendations = [];
15
- const mappedAccounts = accounts === null || accounts === void 0 ? void 0 : accounts.map((acc) => (0, accountPayload_1.mapRecommendedAccountBasePayloadToRecommendedAccountBase)(acc));
16
- const mappedClasses = classObjs === null || classObjs === void 0 ? void 0 : classObjs.map((cls) => (0, classPayload_1.mapRecommendedClassBasePayloadToRecommendedClassBase)(cls));
17
- if (((_a = mappedAccounts === null || mappedAccounts === void 0 ? void 0 : mappedAccounts.length) !== null && _a !== void 0 ? _a : 0) >= ((_b = mappedClasses === null || mappedClasses === void 0 ? void 0 : mappedClasses.length) !== null && _b !== void 0 ? _b : 0)) {
18
- mappedAccounts === null || mappedAccounts === void 0 ? void 0 : mappedAccounts.forEach((acc, index) => {
19
- recommendations.push({
20
- account: acc,
21
- class: mappedClasses === null || mappedClasses === void 0 ? void 0 : mappedClasses[index],
12
+ payload.map((recommendationPayload) => {
13
+ var _a, _b;
14
+ const accounts = recommendationPayload.accounts;
15
+ const classObjs = recommendationPayload.accounting_classes;
16
+ const mappedAccounts = accounts === null || accounts === void 0 ? void 0 : accounts.map((acc) => (0, accountPayload_1.mapRecommendedAccountBasePayloadToRecommendedAccountBase)(acc));
17
+ const mappedClasses = classObjs === null || classObjs === void 0 ? void 0 : classObjs.map((cls) => (0, classPayload_1.mapRecommendedClassBasePayloadToRecommendedClassBase)(cls));
18
+ if (mappedAccounts != null &&
19
+ mappedAccounts.length >= ((_a = mappedClasses === null || mappedClasses === void 0 ? void 0 : mappedClasses.length) !== null && _a !== void 0 ? _a : 0)) {
20
+ mappedAccounts.forEach((account, index) => {
21
+ recommendations.push({
22
+ account,
23
+ class: mappedClasses === null || mappedClasses === void 0 ? void 0 : mappedClasses[index],
24
+ });
22
25
  });
23
- });
24
- }
25
- else {
26
- mappedClasses === null || mappedClasses === void 0 ? void 0 : mappedClasses.forEach((cls, index) => {
27
- recommendations.push({
28
- account: mappedAccounts === null || mappedAccounts === void 0 ? void 0 : mappedAccounts[index],
29
- class: cls,
26
+ }
27
+ else if (mappedClasses != null &&
28
+ mappedClasses.length >= ((_b = mappedAccounts === null || mappedAccounts === void 0 ? void 0 : mappedAccounts.length) !== null && _b !== void 0 ? _b : 0)) {
29
+ mappedClasses.forEach((cls, index) => {
30
+ recommendations.push({
31
+ account: mappedAccounts === null || mappedAccounts === void 0 ? void 0 : mappedAccounts[index],
32
+ class: cls,
33
+ });
30
34
  });
31
- });
32
- }
35
+ }
36
+ });
33
37
  return recommendations;
34
38
  };
35
39
  exports.getRecommendationFromRecommendationPayload = getRecommendationFromRecommendationPayload;
40
+ const getRecommendationByLineIdFromRecommendationPayload = (recommendationPayload, lineIds) => {
41
+ if (recommendationPayload.length === 0) {
42
+ return undefined;
43
+ }
44
+ const recommendationsWithLine = {};
45
+ recommendationPayload.forEach((lineRecommendations, index) => {
46
+ recommendationsWithLine[lineIds[index]] =
47
+ (0, transactionPayload_1.transformRecommendation)(lineRecommendations);
48
+ });
49
+ return recommendationsWithLine;
50
+ };
51
+ exports.getRecommendationByLineIdFromRecommendationPayload = getRecommendationByLineIdFromRecommendationPayload;
@@ -6,7 +6,7 @@ import { SupportedTransaction } from '../../entity/transaction/transactionState'
6
6
  import { ZeniAPIStatus } from '../../responsePayload';
7
7
  import { EntityRecommendationState } from './recommendationState';
8
8
  export declare const initialState: EntityRecommendationState;
9
- export declare const fetchRecommendationByEntityQboId: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, amount: number, transactionDetails: {
9
+ export declare const fetchEntityRecommendationsByTransactionId: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entity: Entity, amount: number, transactionDetails: {
10
10
  transactionId: TransactionID;
11
11
  transaction: SupportedTransaction;
12
12
  lineIds: ID[];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchRecommendationByEntityQboId = exports.initialState = void 0;
4
+ exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const recommendationState_1 = require("./recommendationState");
7
7
  exports.initialState = {
@@ -11,7 +11,7 @@ const recommendation = (0, toolkit_1.createSlice)({
11
11
  name: 'recommendation',
12
12
  initialState: exports.initialState,
13
13
  reducers: {
14
- fetchRecommendationByEntityQboId: {
14
+ fetchEntityRecommendationsByTransactionId: {
15
15
  reducer(draft,
16
16
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
17
  action) {
@@ -101,7 +101,7 @@ const recommendation = (0, toolkit_1.createSlice)({
101
101
  },
102
102
  },
103
103
  });
104
- _a = recommendation.actions, exports.fetchRecommendationByEntityQboId = _a.fetchRecommendationByEntityQboId, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation;
104
+ _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation;
105
105
  exports.default = recommendation.reducer;
106
106
  const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
107
107
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
@@ -1,2 +1,12 @@
1
+ import { CurrentTenant } from '../../entity/tenant/tenantSelector';
2
+ import { RoleMap, UserRoleType } from '../../entity/userRole/userRoleType';
1
3
  import { NotificationSettings } from './settingsViewState';
4
+ export declare const isAccountingTabVisible: (userRole: UserRoleType[], currentTenant: CurrentTenant | undefined) => boolean;
5
+ export declare const isApprovalRulesTabVisible: (userRole: UserRoleType[], currentTenant: CurrentTenant | undefined, userRoleMap?: RoleMap | undefined) => boolean;
6
+ export declare const isBusinessVerificationTabVisible: (userRole: UserRoleType[], currentTenant: CurrentTenant | undefined, userRoleMap?: RoleMap | undefined) => boolean;
7
+ export declare const isBankConnectionsTabVisible: (currentTenant: CurrentTenant | undefined, userRoleMap?: RoleMap | undefined) => boolean;
8
+ export declare const isCompanyDetailsTabVisible: (userRole: UserRoleType[], currentTenant: CurrentTenant | undefined, userRoleMap?: RoleMap | undefined) => boolean;
9
+ export declare const isIntegrationsTabVisible: (userRole: UserRoleType[], currentTenant: CurrentTenant | undefined) => boolean;
10
+ export declare const isSettingsVisible: (currentTenant: CurrentTenant | undefined) => boolean;
11
+ export declare const isMyBankConnectionsTabVisible: (userRole: UserRoleType[], currentTenant: CurrentTenant | undefined) => boolean;
2
12
  export declare const isNotificationsTabVisible: (notificationSettingsView: NotificationSettings) => boolean;