@zeniai/client-epic-state 4.7.99 → 4.8.1

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 (141) hide show
  1. package/lib/commonPayloadTypes/statusPayload.d.ts +4 -0
  2. package/lib/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.d.ts +3 -0
  3. package/lib/commonStateTypes/fiscalYearHelpers/formatZeniDateFY.js +4 -1
  4. package/lib/commonStateTypes/timePeriod.d.ts +9 -2
  5. package/lib/commonStateTypes/timePeriod.js +12 -1
  6. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +1 -1
  7. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -0
  8. package/lib/entity/account/accountPayload.d.ts +1 -1
  9. package/lib/entity/account/accountSelector.d.ts +3 -3
  10. package/lib/entity/account/accountState.d.ts +4 -4
  11. package/lib/entity/account/accountState.js +1 -0
  12. package/lib/entity/account/pickAndMergeForecastAccountReport.d.ts +1 -1
  13. package/lib/entity/accountGroup/accountGroupSelector.d.ts +22 -22
  14. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  15. package/lib/entity/class/classReducer.d.ts +4 -4
  16. package/lib/entity/class/classState.d.ts +2 -2
  17. package/lib/entity/depositAccountTransaction/depositAccountTransaction.d.ts +1 -1
  18. package/lib/entity/forecast/forecastState.d.ts +1 -1
  19. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +55 -0
  20. package/lib/entity/jeSchedules/jeSchedulesPayload.js +142 -0
  21. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +11 -0
  22. package/lib/entity/jeSchedules/jeSchedulesReducer.js +91 -0
  23. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +58 -0
  24. package/lib/entity/jeSchedules/jeSchedulesSelector.js +74 -0
  25. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +61 -0
  26. package/lib/entity/jeSchedules/jeSchedulesState.js +2 -0
  27. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +10 -0
  28. package/lib/entity/jeSchedules/jeSchedulesTypes.js +25 -0
  29. package/lib/entity/jeSchedules/updateJESchedulesEpic.d.ts +10 -0
  30. package/lib/entity/jeSchedules/updateJESchedulesEpic.js +65 -0
  31. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  32. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  33. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  34. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  35. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  36. package/lib/entity/tenant/clearAllEpic.d.ts +3 -1
  37. package/lib/entity/tenant/clearAllEpic.js +4 -0
  38. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +12 -0
  39. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.js +37 -0
  40. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +3 -3
  41. package/lib/entity/transaction/payloadTypes/transactionPayload.js +1 -1
  42. package/lib/entity/transaction/stateTypes/scheduleTransaction.d.ts +11 -0
  43. package/lib/entity/transaction/stateTypes/scheduleTransaction.js +2 -0
  44. package/lib/entity/transaction/stateTypes/transaction.d.ts +10 -7
  45. package/lib/entity/transaction/stateTypes/transactionType.d.ts +4 -0
  46. package/lib/entity/transaction/stateTypes/transactionType.js +11 -3
  47. package/lib/entity/transaction/transactionReducer.d.ts +7 -0
  48. package/lib/entity/transaction/transactionReducer.js +39 -3
  49. package/lib/entity/transaction/transactionSelector.d.ts +6 -0
  50. package/lib/entity/transaction/transactionSelector.js +19 -0
  51. package/lib/entity/transaction/transactionState.d.ts +3 -0
  52. package/lib/epic.d.ts +77 -67
  53. package/lib/epic.js +11 -1
  54. package/lib/index.d.ts +23 -10
  55. package/lib/index.js +60 -17
  56. package/lib/reducer.d.ts +9 -0
  57. package/lib/reducer.js +9 -0
  58. package/lib/view/accountList/accountListReducer.js +2 -0
  59. package/lib/view/accountList/accountListSelector.d.ts +16 -1
  60. package/lib/view/accountList/accountListSelector.js +33 -4
  61. package/lib/view/accountList/accountListState.d.ts +1 -1
  62. package/lib/view/accountMappingView/accountTypeRecommendation/accountTypeRecommendationPayload.d.ts +1 -1
  63. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  64. package/lib/view/cardBalance/cardBalanceSelector.d.ts +2 -2
  65. package/lib/view/cashBalance/cashBalanceSelector.d.ts +2 -2
  66. package/lib/view/cashInCashOut/cashInCashOutSelector.d.ts +1 -1
  67. package/lib/view/cashPosition/cashPositionSelector.d.ts +1 -1
  68. package/lib/view/dashboard/dashboardReducer.d.ts +2 -2
  69. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  70. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  71. package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
  72. package/lib/view/people/deletePersonEpic.d.ts +1 -1
  73. package/lib/view/people/invitePeopleEpic.d.ts +1 -1
  74. package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
  75. package/lib/view/people/resendInviteEpic.d.ts +1 -1
  76. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  77. package/lib/view/reviewCompanyView/reviewCompanyViewState.d.ts +2 -2
  78. package/lib/view/reviewCompanyView/reviewCompanyViewState.js +1 -0
  79. package/lib/view/scheduleView/scheduleDetailView/epics/createNewSchedulesEpic.d.ts +6 -0
  80. package/lib/view/scheduleView/scheduleDetailView/epics/createNewSchedulesEpic.js +28 -0
  81. package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.d.ts +8 -0
  82. package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsEpic.js +51 -0
  83. package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.d.ts +7 -0
  84. package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.js +16 -0
  85. package/lib/view/scheduleView/scheduleDetailView/epics/initializeScheduleDetailLocalDataEpic.d.ts +6 -0
  86. package/lib/view/scheduleView/scheduleDetailView/epics/initializeScheduleDetailLocalDataEpic.js +32 -0
  87. package/lib/view/scheduleView/scheduleDetailView/epics/saveScheduleDetailsEpic.d.ts +11 -0
  88. package/lib/view/scheduleView/scheduleDetailView/epics/saveScheduleDetailsEpic.js +102 -0
  89. package/lib/view/scheduleView/scheduleDetailView/epics/updateAmountsInScheduleDetailEpic.d.ts +6 -0
  90. package/lib/view/scheduleView/scheduleDetailView/epics/updateAmountsInScheduleDetailEpic.js +29 -0
  91. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper.d.ts +18 -0
  92. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper.js +185 -0
  93. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailPayload.d.ts +58 -0
  94. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailPayload.js +118 -0
  95. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailReducer.d.ts +50 -0
  96. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailReducer.js +237 -0
  97. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailSelector.d.ts +21 -0
  98. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailSelector.js +67 -0
  99. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailState.d.ts +47 -0
  100. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailState.js +5 -0
  101. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailTypes.d.ts +3 -0
  102. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailTypes.js +14 -0
  103. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.d.ts +8 -0
  104. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +52 -0
  105. package/lib/view/scheduleView/scheduleListView/epics/fetchScheduleListEpic.d.ts +27 -0
  106. package/lib/view/scheduleView/scheduleListView/epics/fetchScheduleListEpic.js +75 -0
  107. package/lib/view/scheduleView/scheduleListView/epics/fetchSchedulesAccountEpic.d.ts +19 -0
  108. package/lib/view/scheduleView/scheduleListView/epics/fetchSchedulesAccountEpic.js +37 -0
  109. package/lib/view/scheduleView/scheduleListView/scheduleListHelper.d.ts +70 -0
  110. package/lib/view/scheduleView/scheduleListView/scheduleListHelper.js +187 -0
  111. package/lib/view/scheduleView/scheduleListView/scheduleListPayload.d.ts +7 -0
  112. package/lib/view/scheduleView/scheduleListView/scheduleListPayload.js +2 -0
  113. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +55 -0
  114. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +228 -0
  115. package/lib/view/scheduleView/scheduleListView/scheduleListSelector.d.ts +38 -0
  116. package/lib/view/scheduleView/scheduleListView/scheduleListSelector.js +193 -0
  117. package/lib/view/scheduleView/scheduleListView/scheduleListState.d.ts +29 -0
  118. package/lib/view/scheduleView/scheduleListView/scheduleListState.js +2 -0
  119. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +22 -0
  120. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.js +39 -0
  121. package/lib/view/spendManagement/helpers.d.ts +4 -0
  122. package/lib/view/spendManagement/helpers.js +26 -1
  123. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  124. package/lib/view/topEx/topExSelector.d.ts +1 -1
  125. package/lib/view/transactionDetail/epics/initializeTransactionDetailLocalDataEpic.js +2 -5
  126. package/lib/view/transactionDetail/epics/saveTransactionDetailEpic.js +2 -1
  127. package/lib/view/transactionDetail/epics/transactionDetailEpic.js +3 -2
  128. package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +2 -1
  129. package/lib/view/transactionDetail/transactionDetailSelector.js +3 -2
  130. package/lib/view/transactionDetail/transactionDetailState.d.ts +1 -1
  131. package/lib/view/transactionDetail/transactionDetailState.js +3 -16
  132. package/lib/view/transactionList/transactionListByAccountSelector.js +2 -1
  133. package/lib/view/transactionList/transactionListByCategoryTypeSelector.js +2 -1
  134. package/lib/view/transactionList/transactionListByClassSelector.js +2 -1
  135. package/lib/view/transactionList/transactionListByEntitySelector.js +2 -1
  136. package/lib/view/vendorList/vendorListSelector.d.ts +3 -0
  137. package/lib/view/vendorList/vendorListSelector.js +11 -1
  138. package/lib/view/vendorReviewView/vendorGlobalReviewView/vendorGlobalReviewViewState.d.ts +2 -2
  139. package/lib/zeniDayJS.d.ts +1 -0
  140. package/lib/zeniDayJS.js +7 -1
  141. package/package.json +1 -1
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeScheduleDetailLocalDataEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const scheduleDetailReducer_1 = require("../scheduleDetailReducer");
7
+ const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
8
+ const scheduleDetailLocalDataHelper_1 = require("../scheduleDetailLocalDataHelper");
9
+ const initializeScheduleDetailLocalDataEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(scheduleDetailReducer_1.initializeScheduleDetailLocalData.match), (0, operators_1.mergeMap)((action) => {
10
+ const state = state$.value;
11
+ const { scheduleDetailState } = state;
12
+ const actions = [];
13
+ const { selectedJeScheduleDetailId, selectedJEScheduleKey } = action.payload;
14
+ if (selectedJeScheduleDetailId != null) {
15
+ const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(selectedJEScheduleKey, state);
16
+ const scheduledJournalEntry = jeScheduleTransactionState.scheduledJournalEntry;
17
+ if (selectedJEScheduleKey != null) {
18
+ actions.push((0, scheduleDetailReducer_1.updateScheduleDetailsLocalData)({
19
+ selectedJeScheduleDetailId,
20
+ localData: Object.assign(Object.assign({}, scheduleDetailReducer_1.initialScheduleDetailsLocalData), (0, scheduleDetailLocalDataHelper_1.getInitializedJEScheduleDetailsLocalData)(jeScheduleTransactionState, scheduledJournalEntry)),
21
+ }));
22
+ }
23
+ }
24
+ else {
25
+ actions.push((0, scheduleDetailReducer_1.updateScheduleDetailsLocalData)({
26
+ localData: scheduleDetailState.newScheduleState,
27
+ selectedJeScheduleDetailId: undefined,
28
+ }));
29
+ }
30
+ return (0, rxjs_1.from)(actions);
31
+ }));
32
+ exports.initializeScheduleDetailLocalDataEpic = initializeScheduleDetailLocalDataEpic;
@@ -0,0 +1,11 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { ZeniAPI } from '../../../../zeniAPI';
3
+ import { RootState } from '../../../../reducer';
4
+ import { updateJESchedulesDetails, updateJESchedules } from '../../../../entity/jeSchedules/jeSchedulesReducer';
5
+ import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
6
+ import { initializeScheduleDetailLocalData, saveScheduleDetails, saveScheduleDetailsSuccessOrFailure, updateScheduleDetailNewStateLocalData } from '../scheduleDetailReducer';
7
+ export declare type ActionType = ReturnType<typeof saveScheduleDetails> | ReturnType<typeof updateJESchedulesDetails> | ReturnType<typeof updateJESchedules> | ReturnType<typeof updateScheduleDetailNewStateLocalData> | ReturnType<typeof saveScheduleDetailsSuccessOrFailure> | ReturnType<typeof initializeScheduleDetailLocalData> | ReturnType<typeof openSnackbar>;
8
+ export declare const saveScheduleDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
9
+ export interface ScheduleDetailsQueryParam {
10
+ je_schedule_type: string;
11
+ }
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveScheduleDetailsEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../../responsePayload");
7
+ const jeSchedulesReducer_1 = require("../../../../entity/jeSchedules/jeSchedulesReducer");
8
+ const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
9
+ const scheduleDetailReducer_1 = require("../scheduleDetailReducer");
10
+ const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
11
+ const scheduleDetailPayload_1 = require("../scheduleDetailPayload");
12
+ const saveScheduleDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(scheduleDetailReducer_1.saveScheduleDetails.match), (0, operators_1.mergeMap)((action) => {
13
+ var _a;
14
+ const state = state$.value;
15
+ const { scheduleDetailState, scheduleListState } = state;
16
+ const { selectedJeScheduleDetailId } = action.payload;
17
+ const selectedJEScheduleKey = scheduleDetailState.selectedJEScheduleKey;
18
+ const actions = [];
19
+ if (selectedJEScheduleKey == null) {
20
+ return (0, rxjs_1.from)(actions);
21
+ }
22
+ const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(selectedJEScheduleKey, state);
23
+ const vendorName = jeScheduleTransactionState.vendor.name;
24
+ const scheduleDetailId = (_a = jeScheduleTransactionState.jeScheduleId) !== null && _a !== void 0 ? _a : selectedJeScheduleDetailId;
25
+ const scheduleDetailsUpdated = scheduleDetailId != null
26
+ ? state.scheduleDetailState.editScheduleStateById[scheduleDetailId]
27
+ : state.scheduleDetailState.newScheduleState;
28
+ const currentTab = scheduleListState.currentTab;
29
+ const payload = Object.assign({}, (0, scheduleDetailPayload_1.prepareScheduleDetailPayload)(state, scheduleDetailsUpdated, selectedJEScheduleKey, currentTab));
30
+ const queryParam = {
31
+ je_schedule_type: currentTab,
32
+ };
33
+ const saveScheduleDetailsApi = scheduleDetailId != null
34
+ ? zeniAPI.putAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${scheduleDetailId}?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload)
35
+ : zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(queryParam))}`, payload);
36
+ return saveScheduleDetailsApi.pipe((0, operators_1.mergeMap)((response) => {
37
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
38
+ const jeScheduleDetailID = response.data.je_schedules[0].je_schedule_id;
39
+ if (jeScheduleDetailID == null) {
40
+ actions.push((0, scheduleDetailReducer_1.saveScheduleDetailsSuccessOrFailure)('Error', response.status), (0, snackbarReducer_1.openSnackbar)({
41
+ messageSection: scheduleDetailId != null
42
+ ? 'save_schedule'
43
+ : 'create_schedule',
44
+ messageText: 'failed',
45
+ type: 'error',
46
+ variables: [
47
+ {
48
+ variableName: '_api-error_',
49
+ variableValue: 'Schedule returned NULL for ID.',
50
+ },
51
+ ],
52
+ }));
53
+ return (0, rxjs_1.from)(actions);
54
+ }
55
+ actions.push((0, jeSchedulesReducer_1.updateJESchedules)(response.data.je_schedules), (0, jeSchedulesReducer_1.updateJESchedulesDetails)(response.data.je_schedules, response.data.scheduled_journal_entries), (0, scheduleDetailReducer_1.initializeScheduleDetailLocalData)(selectedJEScheduleKey, jeScheduleDetailID), (0, scheduleDetailReducer_1.saveScheduleDetailsSuccessOrFailure)('Completed'), (0, snackbarReducer_1.openSnackbar)({
56
+ messageSection: scheduleDetailId != null
57
+ ? 'save_schedule'
58
+ : 'create_schedule',
59
+ messageText: 'success',
60
+ type: 'success',
61
+ variables: [
62
+ {
63
+ variableName: '_vendor_name_',
64
+ variableValue: vendorName,
65
+ },
66
+ ],
67
+ }));
68
+ return (0, rxjs_1.from)(actions);
69
+ }
70
+ else {
71
+ actions.push((0, scheduleDetailReducer_1.saveScheduleDetailsSuccessOrFailure)('Error', response.status));
72
+ actions.push((0, snackbarReducer_1.openSnackbar)({
73
+ messageSection: scheduleDetailId != null
74
+ ? 'save_schedule'
75
+ : 'create_schedule',
76
+ messageText: 'failed',
77
+ type: 'error',
78
+ variables: [
79
+ {
80
+ variableName: '_api-error_',
81
+ variableValue: response.status.message,
82
+ },
83
+ ],
84
+ }));
85
+ return (0, rxjs_1.from)(actions);
86
+ }
87
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
88
+ (0, snackbarReducer_1.openSnackbar)({
89
+ messageSection: scheduleDetailId != null ? 'save_schedule' : 'create_schedule',
90
+ messageText: 'failed',
91
+ type: 'error',
92
+ variables: [
93
+ {
94
+ variableName: '_api-error_',
95
+ variableValue: JSON.stringify(error),
96
+ },
97
+ ],
98
+ }),
99
+ (0, scheduleDetailReducer_1.saveScheduleDetailsSuccessOrFailure)('Error', (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Save Schedule Detail REST API call errored out ${JSON.stringify(error)}`)),
100
+ ])));
101
+ }));
102
+ exports.saveScheduleDetailsEpic = saveScheduleDetailsEpic;
@@ -0,0 +1,6 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../reducer';
4
+ import { updateScheduleDetailsLocalData, updateAmountsInScheduleDetail } from '../scheduleDetailReducer';
5
+ export declare type ActionType = ReturnType<typeof updateScheduleDetailsLocalData> | ReturnType<typeof updateAmountsInScheduleDetail>;
6
+ export declare const updateAmountsInScheduleDetailEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAmountsInScheduleDetailEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const scheduleDetailReducer_1 = require("../scheduleDetailReducer");
7
+ const jeSchedulesSelector_1 = require("../../../../entity/jeSchedules/jeSchedulesSelector");
8
+ const scheduleDetailLocalDataHelper_1 = require("../scheduleDetailLocalDataHelper");
9
+ const updateAmountsInScheduleDetailEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(scheduleDetailReducer_1.updateAmountsInScheduleDetail.match), (0, operators_1.mergeMap)((action) => {
10
+ var _a;
11
+ const actions = [];
12
+ const state = state$.value;
13
+ const { scheduleDetailState } = state;
14
+ const selectedJEScheduleKey = scheduleDetailState.selectedJEScheduleKey;
15
+ if (selectedJEScheduleKey != null) {
16
+ const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(selectedJEScheduleKey, state);
17
+ const jeScheduleDetailId = action.payload.jeScheduleDetailId;
18
+ const totalAmount = jeScheduleTransactionState.baseTransaction.amount.amount;
19
+ const jeScheduleLocalDataUpdated = (0, scheduleDetailLocalDataHelper_1.updateAmountsInScheduleDetails)(scheduleDetailState.editScheduleStateById[jeScheduleDetailId]
20
+ .jeScheduleDetails, (_a = scheduleDetailState.editScheduleStateById[jeScheduleDetailId]
21
+ .selectedMonths) !== null && _a !== void 0 ? _a : 0, action.payload.rowId, totalAmount);
22
+ actions.push((0, scheduleDetailReducer_1.updateScheduleDetailsLocalData)({
23
+ selectedJeScheduleDetailId: jeScheduleDetailId,
24
+ localData: Object.assign(Object.assign({}, scheduleDetailState.editScheduleStateById[jeScheduleDetailId]), { jeScheduleDetails: jeScheduleLocalDataUpdated }),
25
+ }));
26
+ }
27
+ return (0, rxjs_1.from)(actions);
28
+ }));
29
+ exports.updateAmountsInScheduleDetailEpic = updateAmountsInScheduleDetailEpic;
@@ -0,0 +1,18 @@
1
+ import { Amount } from '../../../commonStateTypes/amount';
2
+ import { JEScheduledTransaction, ScheduledJournalEntry } from '../../../entity/jeSchedules/jeSchedulesSelector';
3
+ import { JEScheduleDetailsLocalData, JETransactionLink, ScheduleDetailsLocalData } from './scheduleDetailState';
4
+ import ZeniUrl from '../../../zeniUrl';
5
+ import { ZeniDate } from '../../../zeniDayJS';
6
+ import { ScheduleJournalEntryStatusCodeType } from '../../../entity/jeSchedules/jeSchedulesTypes';
7
+ import { TransactionID } from '../../../entity/transaction/stateTypes/transaction';
8
+ export declare const DUMMY_TRANSACTION_ID = "dummyid";
9
+ export declare const getPostingDateAndStatusForIndex: (schedulePostingMonth: number, schedulePostingYear: number, postingDay?: 2 | 1 | 22 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | undefined) => {
10
+ postingDate: ZeniDate;
11
+ postingStatus: ScheduleJournalEntryStatusCodeType;
12
+ };
13
+ export declare const createNewSchedulesHelper: (localData: ScheduleDetailsLocalData, totalAmount: Amount, vendorName: string) => JEScheduleDetailsLocalData[];
14
+ export declare const getInitializedJEScheduleDetailsLocalData: (jeScheduleTransactionState: JEScheduledTransaction, scheduleJournalEntryData: ScheduledJournalEntry[]) => ScheduleDetailsLocalData;
15
+ export declare const updateAmountsInScheduleDetails: (jeSchedulesLocalData: JEScheduleDetailsLocalData[], actualPeriod: number, rowId: number, totalAmount: number) => JEScheduleDetailsLocalData[];
16
+ export declare const getQBOUrlForLink: (qboAppUrl: string, jeLink?: JETransactionLink | undefined) => ZeniUrl | undefined;
17
+ export declare const getThirdPartyIDFromQBOURL: (jeLinkURL: ZeniUrl) => JETransactionLink;
18
+ export declare const getJETransactionLinkFromThirdPartyId: (thirdPartyID?: string | undefined, transactionId?: string | undefined, recommendedTransactionID?: TransactionID | undefined) => JETransactionLink;
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getJETransactionLinkFromThirdPartyId = exports.getThirdPartyIDFromQBOURL = exports.getQBOUrlForLink = exports.updateAmountsInScheduleDetails = exports.getInitializedJEScheduleDetailsLocalData = exports.createNewSchedulesHelper = exports.getPostingDateAndStatusForIndex = exports.DUMMY_TRANSACTION_ID = void 0;
4
+ const amount_1 = require("../../../commonStateTypes/amount");
5
+ const zeniUrl_1 = require("../../../zeniUrl");
6
+ const zeniDayJS_1 = require("../../../zeniDayJS");
7
+ const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
8
+ exports.DUMMY_TRANSACTION_ID = 'dummyid';
9
+ const getPostingDateAndStatusForIndex = function (schedulePostingMonth, schedulePostingYear, postingDay) {
10
+ // For the index, (1-12) find the posting date
11
+ const dateOfTransaction = postingDay !== null && postingDay !== void 0 ? postingDay : 31;
12
+ let postingDate = (0, zeniDayJS_1.dateFromYearMonthDate)(schedulePostingYear, schedulePostingMonth, dateOfTransaction);
13
+ if (postingDate.month() !== schedulePostingMonth) {
14
+ postingDate = (0, zeniDayJS_1.dateFromYearMonthDate)(schedulePostingYear, schedulePostingMonth).endOf('month');
15
+ }
16
+ let postingStatus = 'pending';
17
+ if (postingDate.isBefore((0, zeniDayJS_1.dateNow)().startOf('month'))) {
18
+ postingStatus = 'unknown';
19
+ }
20
+ return {
21
+ postingDate,
22
+ postingStatus,
23
+ };
24
+ };
25
+ exports.getPostingDateAndStatusForIndex = getPostingDateAndStatusForIndex;
26
+ const getScheduleMemo = (vendorName, schedulePostingDate, currentPeriod, totalPeriod) => {
27
+ return `${vendorName} - ${schedulePostingDate.format(formatZeniDateFY_1.MONTH_YEAR_FORMAT)} (${currentPeriod} of ${totalPeriod})`;
28
+ };
29
+ const createNewSchedulesHelper = (localData, totalAmount, vendorName) => {
30
+ const period = localData.selectedMonths;
31
+ const startingMonth = localData.selectedDate;
32
+ if (startingMonth == null) {
33
+ return [];
34
+ }
35
+ const newSchedulesData = [];
36
+ if (period == null) {
37
+ return [];
38
+ }
39
+ const averageAmount = Math.abs(Math.round((totalAmount.amount / period) * 100) / 100);
40
+ const lastMonthAmount = Math.abs(Math.round((totalAmount.amount - averageAmount * (period - 1)) * 100) / 100);
41
+ let runningBalance = Math.abs(totalAmount.amount);
42
+ const negativeNumbers = totalAmount.amount < 0 || runningBalance < 0;
43
+ for (let index = 0; index < period; index++) {
44
+ if (runningBalance > averageAmount) {
45
+ runningBalance = Math.round((runningBalance - averageAmount) * 100) / 100;
46
+ }
47
+ else {
48
+ runningBalance = 0;
49
+ }
50
+ const amount = index === period - 1 ? lastMonthAmount : averageAmount;
51
+ runningBalance = index === period - 1 ? 0 : runningBalance;
52
+ const schedulePostingDate = startingMonth.add(index, 'month');
53
+ const { postingDate, postingStatus } = (0, exports.getPostingDateAndStatusForIndex)(schedulePostingDate.month(), schedulePostingDate.year(), localData.lastDayOfMonth === true
54
+ ? undefined
55
+ : localData.selectedDayOfMonth);
56
+ newSchedulesData.push({
57
+ postingDate,
58
+ amount: (0, amount_1.toAmount)(negativeNumbers ? -amount : amount, totalAmount.currencyCode, totalAmount.currencySymbol),
59
+ runningBalance: (0, amount_1.toAmount)(negativeNumbers ? -runningBalance : runningBalance, totalAmount.currencyCode, totalAmount.currencySymbol),
60
+ postingStatus,
61
+ memo: getScheduleMemo(vendorName, schedulePostingDate, index + 1, period),
62
+ jeLink: {
63
+ type: 'unknown',
64
+ },
65
+ });
66
+ }
67
+ return newSchedulesData;
68
+ };
69
+ exports.createNewSchedulesHelper = createNewSchedulesHelper;
70
+ const getInitializedJEScheduleDetailsLocalData = (jeScheduleTransactionState, scheduleJournalEntryData) => {
71
+ var _a, _b;
72
+ const jeScheduleDetailsLocalData = scheduleJournalEntryData.map((schedule) => {
73
+ var _a, _b, _c, _d;
74
+ return {
75
+ postingDate: schedule.expectedPostDate,
76
+ amount: (0, amount_1.toAmount)((schedule === null || schedule === void 0 ? void 0 : schedule.amount) ? schedule.amount.amount : 0, (_a = schedule === null || schedule === void 0 ? void 0 : schedule.currencyCode) !== null && _a !== void 0 ? _a : '', (_b = schedule === null || schedule === void 0 ? void 0 : schedule.currencySymbol) !== null && _b !== void 0 ? _b : ''),
77
+ runningBalance: (0, amount_1.toAmount)((schedule === null || schedule === void 0 ? void 0 : schedule.runningBalance) ? schedule.runningBalance.amount : 0, (_c = schedule === null || schedule === void 0 ? void 0 : schedule.currencyCode) !== null && _c !== void 0 ? _c : '', (_d = schedule === null || schedule === void 0 ? void 0 : schedule.currencySymbol) !== null && _d !== void 0 ? _d : ''),
78
+ postingStatus: schedule.status.code,
79
+ memo: schedule.memo,
80
+ jeLink: (0, exports.getJETransactionLinkFromThirdPartyId)(schedule.thirdPartyID, schedule.transactionID, schedule.recommendedTransactionID),
81
+ };
82
+ });
83
+ const { startDate, period, jeDebit, dayOfPostingDate, lastDayOfMonth } = jeScheduleTransactionState;
84
+ return {
85
+ jeScheduleDetails: jeScheduleDetailsLocalData,
86
+ selectedDate: startDate,
87
+ selectedMonths: period,
88
+ selectedAccount: (_a = jeDebit.account) === null || _a === void 0 ? void 0 : _a.accountId,
89
+ selectedClass: (_b = jeDebit.accountingClass) === null || _b === void 0 ? void 0 : _b.classId,
90
+ selectedDayOfMonth: dayOfPostingDate,
91
+ lastDayOfMonth: lastDayOfMonth,
92
+ };
93
+ };
94
+ exports.getInitializedJEScheduleDetailsLocalData = getInitializedJEScheduleDetailsLocalData;
95
+ const updateAmountsInScheduleDetails = (jeSchedulesLocalData, actualPeriod, rowId, totalAmount) => {
96
+ const updatedAmount = Math.abs(jeSchedulesLocalData[rowId].amount.amount);
97
+ const absTotalAmount = Math.abs(totalAmount);
98
+ let calculatedRunningBalance = 0;
99
+ if (rowId === 0) {
100
+ calculatedRunningBalance = absTotalAmount - updatedAmount;
101
+ }
102
+ else {
103
+ calculatedRunningBalance =
104
+ Math.abs(jeSchedulesLocalData[rowId - 1].runningBalance.amount) -
105
+ updatedAmount;
106
+ }
107
+ const calculatedPeriod = actualPeriod - (rowId + 1);
108
+ const averageAmount = Math.round((calculatedRunningBalance / calculatedPeriod) * 100) / 100;
109
+ const lastMonthAmount = Math.abs(Math.round((calculatedRunningBalance - averageAmount * (calculatedPeriod - 1)) * 100) / 100);
110
+ let currentRunningBalance = calculatedRunningBalance;
111
+ const isNegative = totalAmount < 0 || currentRunningBalance < 0;
112
+ return jeSchedulesLocalData.map((jeScheduleDetail, index) => {
113
+ if (index > rowId) {
114
+ if (currentRunningBalance - averageAmount > 0) {
115
+ currentRunningBalance =
116
+ Math.round((currentRunningBalance - averageAmount) * 100) / 100;
117
+ }
118
+ else {
119
+ currentRunningBalance = 0;
120
+ }
121
+ const amount = index === actualPeriod - 1 ? lastMonthAmount : averageAmount;
122
+ currentRunningBalance =
123
+ index === actualPeriod - 1 ? 0 : currentRunningBalance;
124
+ return Object.assign(Object.assign({}, jeScheduleDetail), { amount: Object.assign(Object.assign({}, jeScheduleDetail.amount), { amount: isNegative && amount !== 0 ? -amount : amount }), runningBalance: Object.assign(Object.assign({}, jeScheduleDetail.runningBalance), { amount: isNegative && currentRunningBalance !== 0
125
+ ? -currentRunningBalance
126
+ : currentRunningBalance }), postingStatus: amount === 0 ? 'canceled' : 'pending' });
127
+ }
128
+ else if (index === rowId) {
129
+ return Object.assign(Object.assign({}, jeScheduleDetail), { amount: Object.assign(Object.assign({}, jeScheduleDetail.amount), { amount: isNegative && updatedAmount !== 0 ? -updatedAmount : updatedAmount }), runningBalance: Object.assign(Object.assign({}, jeScheduleDetail.runningBalance), { amount: isNegative && calculatedRunningBalance !== 0
130
+ ? -calculatedRunningBalance
131
+ : calculatedRunningBalance }), postingStatus: updatedAmount === 0 ? 'canceled' : 'pending' });
132
+ }
133
+ else {
134
+ return jeScheduleDetail;
135
+ }
136
+ });
137
+ };
138
+ exports.updateAmountsInScheduleDetails = updateAmountsInScheduleDetails;
139
+ const getQBOUrlForLink = (qboAppUrl, jeLink) => {
140
+ return (jeLink === null || jeLink === void 0 ? void 0 : jeLink.thirdPartyTransactionId) != null
141
+ ? (0, zeniUrl_1.toZeniUrl)(`${qboAppUrl}/journal?txnid=` + jeLink.thirdPartyTransactionId)
142
+ : undefined;
143
+ };
144
+ exports.getQBOUrlForLink = getQBOUrlForLink;
145
+ // URL is of the format https://app.qbo.intuit.com/app/journal?txnid=33058
146
+ const getThirdPartyIDFromQBOURL = (jeLinkURL) => {
147
+ const id = jeLinkURL.toString().split('=');
148
+ const thirdPartyID = id.length >= 1 ? id[1] : undefined;
149
+ // recommended type means recommended transaction id is present
150
+ // linked is when thirdparty and transaction details id are present
151
+ // unknown is when all are absent
152
+ // qbourl is when only third party is provided
153
+ return {
154
+ type: 'qbourl',
155
+ thirdPartyTransactionId: thirdPartyID,
156
+ transactionDetailID: thirdPartyID != null
157
+ ? {
158
+ id: `${exports.DUMMY_TRANSACTION_ID}:${thirdPartyID}`,
159
+ type: 'journal_entry',
160
+ }
161
+ : undefined,
162
+ };
163
+ };
164
+ exports.getThirdPartyIDFromQBOURL = getThirdPartyIDFromQBOURL;
165
+ const getJETransactionLinkFromThirdPartyId = (thirdPartyID, transactionId, recommendedTransactionID) => {
166
+ const type = transactionId != null
167
+ ? 'linked'
168
+ : thirdPartyID == null
169
+ ? recommendedTransactionID == null
170
+ ? 'unknown'
171
+ : 'recommended'
172
+ : 'qbourl';
173
+ return {
174
+ type,
175
+ thirdPartyTransactionId: thirdPartyID,
176
+ recommendedTransactionID: recommendedTransactionID,
177
+ transactionDetailID: transactionId != null
178
+ ? {
179
+ id: transactionId,
180
+ type: 'journal_entry',
181
+ }
182
+ : undefined,
183
+ };
184
+ };
185
+ exports.getJETransactionLinkFromThirdPartyId = getJETransactionLinkFromThirdPartyId;
@@ -0,0 +1,58 @@
1
+ import { RootState } from '../../../reducer';
2
+ import { JEScheduleDetailsLocalData, ScheduleDetailsLocalData } from './scheduleDetailState';
3
+ import { JEScheduleKey, SchedulesTypes } from '../../../entity/jeSchedules/jeSchedulesTypes';
4
+ import { VendorBasePayload } from '../../../entity/vendor/vendorPayload';
5
+ import { JEScheduledTransaction } from '../../../entity/jeSchedules/jeSchedulesSelector';
6
+ import { Vendor, VendorState } from '../../../entity/vendor/vendorState';
7
+ import { ScheduleTransaction } from '../../../entity/transaction/stateTypes/scheduleTransaction';
8
+ import { AccountBasePayload } from '../../../entity/account/accountPayload';
9
+ import { ClassBasePayload } from '../../../entity/class/classPayload';
10
+ import { TransactionIDPayload } from '../../../entity/transaction/payloadTypes/transactionIDPayload';
11
+ import { StatusCodeWithLabelPayload } from '../../../commonPayloadTypes/statusPayload';
12
+ export declare type BaseScheduleTransactionPayload = SaveScheduleTransactionPayload;
13
+ export interface JESchedulePayload {
14
+ status: StatusCodeWithLabelPayload;
15
+ vendor: VendorBasePayload;
16
+ currency_code: string;
17
+ currency_symbol: string;
18
+ base_transaction: BaseScheduleTransactionPayload;
19
+ je_schedule_type: string;
20
+ period: number | null;
21
+ balance: number | null;
22
+ posting_date: number | null;
23
+ start_date: string | null;
24
+ end_date: string | null;
25
+ je_credit_accounting_class_id: string | null;
26
+ je_credit_account_id: string | null;
27
+ je_debit_account_id: string | null;
28
+ je_debit_accounting_class_id: string | null;
29
+ }
30
+ export interface SaveJESchedulePayload {
31
+ status: StatusCodeWithLabelPayload;
32
+ transaction_memo: string | null;
33
+ third_party_id: string | null;
34
+ expected_post_date: string | null;
35
+ je_schedule_id: string | null;
36
+ scheduled_journal_entry_id: string | null;
37
+ actual_post_date: string | null;
38
+ amount: number | null;
39
+ balance: number | null;
40
+ is_platform_generated: boolean | null;
41
+ update_time: string | null;
42
+ create_time: string | null;
43
+ }
44
+ export interface SaveScheduleTransactionPayload extends TransactionIDPayload, Omit<AccountBasePayload, 'qbo_id'>, Omit<ClassBasePayload, 'qbo_id'> {
45
+ third_party_transaction_id: string | null;
46
+ transaction_date: string | null;
47
+ total_amount: number | null;
48
+ transaction_memo: string | null;
49
+ }
50
+ export interface SaveScheduleDetailPayload {
51
+ je_schedules: JESchedulePayload[];
52
+ scheduled_journal_entries: SaveJESchedulePayload[];
53
+ }
54
+ export declare const mapVendorToVendorPayload: (payload: Vendor) => VendorBasePayload;
55
+ export declare const mapScheduleTransactionToBaseScheduleTransactionPayload: (payload: ScheduleTransaction) => BaseScheduleTransactionPayload;
56
+ export declare const mapJEScheduleLocalDataToScheduleDetailPayload: (jeScheduleDetails: JEScheduleDetailsLocalData[], jeScheduleTransactionState: JEScheduledTransaction) => SaveJESchedulePayload[];
57
+ export declare const mapJEScheduleTransactionToPayload: (jeScheduleTransactionState: JEScheduledTransaction, vendorState: VendorState, scheduleDetailsLocalData: ScheduleDetailsLocalData, jeScheduleType: SchedulesTypes) => JESchedulePayload;
58
+ export declare const prepareScheduleDetailPayload: (state: RootState, scheduleDetailsLocalData: ScheduleDetailsLocalData, selectedJEScheduleKey: JEScheduleKey, jeScheduleType: SchedulesTypes) => SaveScheduleDetailPayload;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareScheduleDetailPayload = exports.mapJEScheduleTransactionToPayload = exports.mapJEScheduleLocalDataToScheduleDetailPayload = exports.mapScheduleTransactionToBaseScheduleTransactionPayload = exports.mapVendorToVendorPayload = void 0;
4
+ const jeSchedulesSelector_1 = require("../../../entity/jeSchedules/jeSchedulesSelector");
5
+ const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
6
+ const formatZeniDateFY_1 = require("../../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
7
+ const mapVendorToVendorPayload = (payload) => ({
8
+ vendor_id: payload.id,
9
+ vendor_name: payload.name,
10
+ });
11
+ exports.mapVendorToVendorPayload = mapVendorToVendorPayload;
12
+ const mapScheduleTransactionToBaseScheduleTransactionPayload = (payload) => {
13
+ var _a, _b;
14
+ return {
15
+ transaction_id: payload.id,
16
+ transaction_type: payload.type,
17
+ transaction_date: payload.date.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
18
+ total_amount: payload.amount.amount,
19
+ third_party_transaction_id: payload.thirdPartyTransactionId,
20
+ transaction_memo: payload.memo,
21
+ account_id: payload.account.accountId,
22
+ accounting_class_id: payload.classBase != null ? payload.classBase.classId : '',
23
+ labels: [],
24
+ account_name: (_b = (_a = payload.account) === null || _a === void 0 ? void 0 : _a.accountName) !== null && _b !== void 0 ? _b : '',
25
+ accounting_class_name: payload.classBase != null ? payload.classBase.className : '',
26
+ };
27
+ };
28
+ exports.mapScheduleTransactionToBaseScheduleTransactionPayload = mapScheduleTransactionToBaseScheduleTransactionPayload;
29
+ const mapJEScheduleLocalDataToScheduleDetailPayload = (jeScheduleDetails, jeScheduleTransactionState) => {
30
+ const scheduleJournalEntry = jeScheduleTransactionState.scheduledJournalEntry;
31
+ return jeScheduleDetails.length > 0
32
+ ? jeScheduleDetails.map((journalEntry, index) => {
33
+ var _a;
34
+ const currentScheduleJournalEntry = scheduleJournalEntry[index];
35
+ return {
36
+ status: {
37
+ code: journalEntry.postingStatus,
38
+ label: journalEntry.postingStatus,
39
+ },
40
+ transaction_memo: journalEntry.memo,
41
+ third_party_id: (_a = journalEntry.jeLink.thirdPartyTransactionId) !== null && _a !== void 0 ? _a : null,
42
+ expected_post_date: journalEntry.postingDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT),
43
+ amount: journalEntry.amount.amount,
44
+ balance: journalEntry.runningBalance.amount,
45
+ scheduled_journal_entry_id: (currentScheduleJournalEntry === null || currentScheduleJournalEntry === void 0 ? void 0 : currentScheduleJournalEntry.scheduledJournalEntryID) != null
46
+ ? currentScheduleJournalEntry.scheduledJournalEntryID
47
+ : null,
48
+ actual_post_date: (currentScheduleJournalEntry === null || currentScheduleJournalEntry === void 0 ? void 0 : currentScheduleJournalEntry.actualPostDate) != null
49
+ ? currentScheduleJournalEntry.actualPostDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)
50
+ : null,
51
+ is_platform_generated: (currentScheduleJournalEntry === null || currentScheduleJournalEntry === void 0 ? void 0 : currentScheduleJournalEntry.isPlatformGenerated) != null
52
+ ? currentScheduleJournalEntry.isPlatformGenerated
53
+ : null,
54
+ je_schedule_id: (currentScheduleJournalEntry === null || currentScheduleJournalEntry === void 0 ? void 0 : currentScheduleJournalEntry.jeScheduleId) != null
55
+ ? currentScheduleJournalEntry.jeScheduleId
56
+ : null,
57
+ update_time: (currentScheduleJournalEntry === null || currentScheduleJournalEntry === void 0 ? void 0 : currentScheduleJournalEntry.updateTime) != null
58
+ ? currentScheduleJournalEntry.updateTime.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)
59
+ : null,
60
+ create_time: (currentScheduleJournalEntry === null || currentScheduleJournalEntry === void 0 ? void 0 : currentScheduleJournalEntry.createTime) != null
61
+ ? currentScheduleJournalEntry.createTime.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)
62
+ : null,
63
+ };
64
+ })
65
+ : [];
66
+ };
67
+ exports.mapJEScheduleLocalDataToScheduleDetailPayload = mapJEScheduleLocalDataToScheduleDetailPayload;
68
+ const mapJEScheduleTransactionToPayload = (jeScheduleTransactionState, vendorState, scheduleDetailsLocalData, jeScheduleType) => {
69
+ var _a, _b;
70
+ const { vendor, currencyCode, currencySymbol, baseTransaction, status, startDate, endDate, } = jeScheduleTransactionState;
71
+ const { selectedMonths, selectedAccount, selectedClass, selectedDayOfMonth, lastDayOfMonth, } = scheduleDetailsLocalData;
72
+ const postingDate = selectedDayOfMonth !== null && selectedDayOfMonth !== void 0 ? selectedDayOfMonth : (lastDayOfMonth != null ? timePeriod_1.LAST_SCHEDULE_DAY_OF_MONTH : null);
73
+ const scheduleLength = scheduleDetailsLocalData.jeScheduleDetails.length;
74
+ const firstJEScheduleDate = scheduleLength > 0
75
+ ? scheduleDetailsLocalData.jeScheduleDetails[0].postingDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)
76
+ : null;
77
+ const lastJEScheduleDate = scheduleLength > 0
78
+ ? scheduleDetailsLocalData.jeScheduleDetails[scheduleLength - 1].postingDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)
79
+ : null;
80
+ const vendorID = vendor.id;
81
+ const vendorDetails = vendorState.vendorByID[vendorID];
82
+ return {
83
+ status,
84
+ vendor: (0, exports.mapVendorToVendorPayload)(vendorDetails),
85
+ currency_code: currencyCode,
86
+ currency_symbol: currencySymbol,
87
+ period: selectedMonths !== null && selectedMonths !== void 0 ? selectedMonths : null,
88
+ je_schedule_type: jeScheduleType,
89
+ posting_date: postingDate,
90
+ balance: baseTransaction.amount.amount,
91
+ start_date: (_a = startDate === null || startDate === void 0 ? void 0 : startDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)) !== null && _a !== void 0 ? _a : firstJEScheduleDate,
92
+ end_date: (_b = endDate === null || endDate === void 0 ? void 0 : endDate.format(formatZeniDateFY_1.DEFAULT_DATE_FORMAT)) !== null && _b !== void 0 ? _b : lastJEScheduleDate,
93
+ je_credit_accounting_class_id: baseTransaction.classBase
94
+ ? baseTransaction.classBase.classId
95
+ : null,
96
+ je_credit_account_id: baseTransaction.account.accountId,
97
+ je_debit_account_id: selectedAccount !== null && selectedAccount !== void 0 ? selectedAccount : null,
98
+ je_debit_accounting_class_id: selectedClass !== null && selectedClass !== void 0 ? selectedClass : null,
99
+ base_transaction: (0, exports.mapScheduleTransactionToBaseScheduleTransactionPayload)(baseTransaction),
100
+ };
101
+ };
102
+ exports.mapJEScheduleTransactionToPayload = mapJEScheduleTransactionToPayload;
103
+ const prepareScheduleDetailPayload = (state, scheduleDetailsLocalData, selectedJEScheduleKey, jeScheduleType) => {
104
+ const payload = {
105
+ je_schedules: [],
106
+ scheduled_journal_entries: [],
107
+ };
108
+ const jeScheduleTransactionState = (0, jeSchedulesSelector_1.getJEScheduledTransactionByJEScheduleKey)(selectedJEScheduleKey, state);
109
+ const { vendorState } = state;
110
+ const jeScheduleDetailsLocalData = scheduleDetailsLocalData.jeScheduleDetails;
111
+ payload.je_schedules = [
112
+ (0, exports.mapJEScheduleTransactionToPayload)(jeScheduleTransactionState, vendorState, scheduleDetailsLocalData, jeScheduleType),
113
+ ];
114
+ payload.scheduled_journal_entries =
115
+ (0, exports.mapJEScheduleLocalDataToScheduleDetailPayload)(jeScheduleDetailsLocalData, jeScheduleTransactionState);
116
+ return payload;
117
+ };
118
+ exports.prepareScheduleDetailPayload = prepareScheduleDetailPayload;
@@ -0,0 +1,50 @@
1
+ import { ScheduleDetailsLocalData, ScheduleDetailViewState } from './scheduleDetailState';
2
+ import { JEScheduleKey } from '../../../entity/jeSchedules/jeSchedulesTypes';
3
+ import { FetchState, ID } from '../../../commonStateTypes/common';
4
+ import { ZeniAPIStatus } from '../../../responsePayload';
5
+ import ZeniUrl from '../../../zeniUrl';
6
+ import { ScheduledJournalEntry } from '../../../entity/jeSchedules/jeSchedulesSelector';
7
+ export declare const initialScheduleDetailsLocalData: ScheduleDetailsLocalData;
8
+ export declare const initialState: ScheduleDetailViewState;
9
+ export declare const createNewSchedules: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, fetchScheduleDetailsPage: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", selectedJeScheduleDetailId?: string | undefined], {
10
+ tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
11
+ selectedJeScheduleDetailId: string | undefined;
12
+ }, string, never, never>, fetchScheduleDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue", selectedJeScheduleDetailId?: string | undefined], {
13
+ tab: "prepaid_expenses" | "fixed_assets" | "accured_expenses" | "deferred_revenue";
14
+ selectedJeScheduleDetailId: string | undefined;
15
+ }, string, never, never>, updateScheduleDetailsSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateScheduleDetailsFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
16
+ error?: ZeniAPIStatus<Record<string, unknown>> | undefined;
17
+ }, string>, saveScheduleDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedJeScheduleDetailId?: string | undefined], {
18
+ selectedJeScheduleDetailId: string | undefined;
19
+ }, string, never, never>, saveScheduleDetailsSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[fetchState: FetchState, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
20
+ fetchState: FetchState;
21
+ error: ZeniAPIStatus<Record<string, unknown>> | undefined;
22
+ }, string, never, never>, initializeScheduleDetailLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedJEScheduleKey: `${string}_expense` | `${string}_invoice` | `${string}_payment` | `${string}_credit_memo` | `${string}_sales_receipt` | `${string}_delayed_credit` | `${string}_delayed_charge` | `${string}_refund` | `${string}_check` | `${string}_bill` | `${string}_bill_payment` | `${string}_bill_payment_check` | `${string}_bill_payment_credit_card` | `${string}_vendor_credit` | `${string}_credit_card_credit` | `${string}_transfer` | `${string}_credit_card_payment` | `${string}_deposit` | `${string}_journal_entry`, selectedJeScheduleDetailId?: string | undefined], {
23
+ selectedJEScheduleKey: `${string}_expense` | `${string}_invoice` | `${string}_payment` | `${string}_credit_memo` | `${string}_sales_receipt` | `${string}_delayed_credit` | `${string}_delayed_charge` | `${string}_refund` | `${string}_check` | `${string}_bill` | `${string}_bill_payment` | `${string}_bill_payment_check` | `${string}_bill_payment_credit_card` | `${string}_vendor_credit` | `${string}_credit_card_credit` | `${string}_transfer` | `${string}_credit_card_payment` | `${string}_deposit` | `${string}_journal_entry`;
24
+ selectedJeScheduleDetailId: string | undefined;
25
+ }, string, never, never>, updateScheduleDetailsLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
26
+ selectedJeScheduleDetailId?: string | undefined;
27
+ localData: Partial<ScheduleDetailsLocalData>;
28
+ }, string>, updatedJELinkInLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
29
+ jeScheduleDetailId: ID;
30
+ rowId: number;
31
+ jeLink: ZeniUrl;
32
+ }, string>, updateAmountsInScheduleDetail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[rowId: number, jeScheduleDetailId: string], {
33
+ rowId: number;
34
+ jeScheduleDetailId: string;
35
+ }, string, never, never>, updateScheduleDetailNewStateLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[selectedJeScheduleDetailId: string], {
36
+ selectedJeScheduleDetailId: string;
37
+ }, string, never, never>, updateSelectedJEScheduleKey: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
38
+ selectedJEScheduleKey: JEScheduleKey;
39
+ }, string>, updatedSelectedJELinkRowIndex: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
40
+ selectedJELinkRowIndex: number;
41
+ }, string>, updatedJELinkWithRecommendedLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
42
+ jeScheduleDetailId: ID;
43
+ rowId: number;
44
+ }, string>, resetJELinkInLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
45
+ jeScheduleDetailId: ID;
46
+ rowId: number;
47
+ originalScheduledJE: ScheduledJournalEntry;
48
+ }, string>, clearScheduleDetailView: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
49
+ declare const _default: import("@reduxjs/toolkit").Reducer<ScheduleDetailViewState, import("@reduxjs/toolkit").AnyAction>;
50
+ export default _default;