@zeniai/client-epic-state 5.0.44-betaML3 → 5.0.44-betaRD2

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 (120) hide show
  1. package/lib/commonStateTypes/recommendationBase.d.ts +1 -1
  2. package/lib/commonStateTypes/viewAndReport/viewAndReport.d.ts +2 -2
  3. package/lib/commonStateTypes/viewAndReport/viewAndReport.js +1 -1
  4. package/lib/entity/account/accountSelector.d.ts +0 -5
  5. package/lib/entity/account/accountSelector.js +1 -8
  6. package/lib/entity/account/accountState.d.ts +1 -1
  7. package/lib/entity/accountGroup/accountGroupState.d.ts +1 -1
  8. package/lib/entity/class/classReducer.d.ts +4 -4
  9. package/lib/entity/class/classState.d.ts +1 -1
  10. package/lib/entity/forecast/forecastState.d.ts +1 -1
  11. package/lib/entity/project/projectPayload.d.ts +7 -0
  12. package/lib/entity/project/projectPayload.js +15 -1
  13. package/lib/entity/sectionAccountsView/sectionAccountsView.d.ts +1 -1
  14. package/lib/entity/sectionClassesViewV2/sectionClassesView.d.ts +1 -1
  15. package/lib/entity/sectionClassesViewV2/sectionClassesViewReducer.d.ts +2 -2
  16. package/lib/entity/sectionProjectView/sectionProjectView.d.ts +1 -1
  17. package/lib/entity/sectionProjectView/sectionProjectViewReducer.d.ts +2 -2
  18. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  19. package/lib/entity/snackbar/snackbarTypes.js +0 -2
  20. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  21. package/lib/entity/tenant/clearAllEpic.js +2 -0
  22. package/lib/entity/transaction/payloadTypes/transactionLinePayload.d.ts +2 -0
  23. package/lib/entity/transaction/payloadTypes/transactionLinePayload.js +9 -0
  24. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +0 -6
  25. package/lib/entity/transaction/payloadTypes/transactionPayload.js +0 -10
  26. package/lib/entity/transaction/stateTypes/transaction.d.ts +0 -3
  27. package/lib/entity/transaction/stateTypes/transactionLine.d.ts +2 -0
  28. package/lib/epic.d.ts +4 -3
  29. package/lib/epic.js +4 -3
  30. package/lib/esm/commonStateTypes/viewAndReport/viewAndReport.js +1 -1
  31. package/lib/esm/entity/account/accountSelector.js +0 -6
  32. package/lib/esm/entity/project/projectPayload.js +12 -0
  33. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
  34. package/lib/esm/entity/tenant/clearAllEpic.js +2 -0
  35. package/lib/esm/entity/transaction/payloadTypes/transactionLinePayload.js +9 -0
  36. package/lib/esm/entity/transaction/payloadTypes/transactionPayload.js +0 -10
  37. package/lib/esm/epic.js +4 -3
  38. package/lib/esm/index.js +11 -8
  39. package/lib/esm/reducer.js +3 -0
  40. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +1 -5
  41. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +1 -66
  42. package/lib/esm/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -19
  43. package/lib/esm/view/projectList/fetchProjectListEpic.js +38 -0
  44. package/lib/esm/view/projectList/projectListPayload.js +1 -0
  45. package/lib/esm/view/projectList/projectListReducer.js +39 -0
  46. package/lib/esm/view/projectList/projectListSelector.js +9 -0
  47. package/lib/esm/view/projectList/projectListState.js +1 -0
  48. package/lib/esm/view/transactionDetail/epics/saveTransactionHelper.js +1 -0
  49. package/lib/esm/view/transactionDetail/epics/transactionDetailEpic.js +6 -6
  50. package/lib/esm/view/transactionDetail/epics/updateTransactionDetailEpic.js +3 -0
  51. package/lib/esm/view/transactionDetail/transactionDetailSelector.js +14 -13
  52. package/lib/esm/view/transactionList/fetchTransactionListByProjectEpic.js +45 -0
  53. package/lib/esm/view/transactionList/parallelFetchProjectTransactionListEpic.js +32 -0
  54. package/lib/esm/view/transactionList/transactionListByProjectSelector.js +58 -0
  55. package/lib/esm/view/transactionList/transactionListReducer.js +83 -2
  56. package/lib/esm/view/transactionList/transactionListState.js +10 -0
  57. package/lib/index.d.ts +11 -8
  58. package/lib/index.js +43 -42
  59. package/lib/reducer.d.ts +3 -0
  60. package/lib/reducer.js +3 -0
  61. package/lib/tsconfig.typecheck.tsbuildinfo +1 -1
  62. package/lib/view/auditReportView/auditReportViewState.d.ts +1 -1
  63. package/lib/view/billPayCard/billPayCardSelector.d.ts +1 -1
  64. package/lib/view/cardBalance/cardBalanceSelector.d.ts +1 -1
  65. package/lib/view/cashBalance/cashBalanceSelector.d.ts +1 -1
  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/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.d.ts +2 -2
  70. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationViewEpic.js +0 -4
  71. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  72. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +1 -15
  73. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +2 -67
  74. package/lib/view/expenseAutomationView/selectorTypes/transactionsViewSelectorTypes.d.ts +1 -3
  75. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.d.ts +0 -2
  76. package/lib/view/expenseAutomationView/selectors/transactionCategorizationSelector.js +0 -20
  77. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +1 -13
  78. package/lib/view/financeStatement/financeStatementReducer.d.ts +1 -1
  79. package/lib/view/globalMerchantView/globalMerchantViewReducer.d.ts +2 -2
  80. package/lib/view/projectList/fetchProjectListEpic.d.ts +8 -0
  81. package/lib/view/projectList/fetchProjectListEpic.js +42 -0
  82. package/lib/view/projectList/projectListPayload.d.ts +7 -0
  83. package/lib/view/projectList/projectListPayload.js +2 -0
  84. package/lib/view/projectList/projectListReducer.d.ts +9 -0
  85. package/lib/view/projectList/projectListReducer.js +43 -0
  86. package/lib/view/projectList/projectListSelector.d.ts +8 -0
  87. package/lib/view/projectList/projectListSelector.js +13 -0
  88. package/lib/view/projectList/projectListState.d.ts +4 -0
  89. package/lib/view/projectList/projectListState.js +2 -0
  90. package/lib/view/reimbursementCard/reimbursementCardSelector.d.ts +1 -1
  91. package/lib/view/reportsResync/reportsResyncReducer.d.ts +2 -2
  92. package/lib/view/tasksCard/tasksCardSelector.d.ts +1 -1
  93. package/lib/view/topEx/topExSelector.d.ts +1 -1
  94. package/lib/view/transactionDetail/epics/saveTransactionHelper.js +1 -0
  95. package/lib/view/transactionDetail/epics/transactionDetailEpic.d.ts +2 -2
  96. package/lib/view/transactionDetail/epics/transactionDetailEpic.js +6 -6
  97. package/lib/view/transactionDetail/epics/updateTransactionDetailEpic.js +3 -0
  98. package/lib/view/transactionDetail/transactionDetailPayload.d.ts +1 -1
  99. package/lib/view/transactionDetail/transactionDetailSelector.d.ts +4 -4
  100. package/lib/view/transactionDetail/transactionDetailSelector.js +13 -12
  101. package/lib/view/transactionDetail/transactionDetailState.d.ts +2 -0
  102. package/lib/view/transactionDetail/transactionDetailTypes.d.ts +2 -0
  103. package/lib/view/transactionList/fetchTransactionListByProjectEpic.d.ts +8 -0
  104. package/lib/view/transactionList/fetchTransactionListByProjectEpic.js +52 -0
  105. package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.d.ts +6 -0
  106. package/lib/view/transactionList/parallelFetchProjectTransactionListEpic.js +36 -0
  107. package/lib/view/transactionList/transactionListByProjectSelector.d.ts +22 -0
  108. package/lib/view/transactionList/transactionListByProjectSelector.js +66 -0
  109. package/lib/view/transactionList/transactionListPayload.d.ts +15 -0
  110. package/lib/view/transactionList/transactionListReducer.d.ts +25 -2
  111. package/lib/view/transactionList/transactionListReducer.js +83 -2
  112. package/lib/view/transactionList/transactionListState.d.ts +15 -0
  113. package/lib/view/transactionList/transactionListState.js +13 -1
  114. package/package.json +1 -1
  115. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/createTransferEntryEpic.js +0 -81
  116. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransferAccountsEpic.js +0 -25
  117. package/lib/view/expenseAutomationView/epics/transactionCategorization/createTransferEntryEpic.d.ts +0 -9
  118. package/lib/view/expenseAutomationView/epics/transactionCategorization/createTransferEntryEpic.js +0 -85
  119. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransferAccountsEpic.d.ts +0 -8
  120. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransferAccountsEpic.js +0 -29
@@ -6,7 +6,7 @@ import { Entity } from '../../entity/genericEntity/entity';
6
6
  import { TransactionPayload } from '../../entity/transaction/payloadTypes/transactionPayload';
7
7
  import { TransactionID } from '../../entity/transaction/stateTypes/transaction';
8
8
  import { ZeniAPIStatus } from '../../responsePayload';
9
- import { TransactionListByAccountPayload, TransactionListByClassPayload, TransactionListByEntityPayload } from './transactionListPayload';
9
+ import { TransactionListByAccountPayload, TransactionListByClassPayload, TransactionListByEntityPayload, TransactionListByProjectPayload } from './transactionListPayload';
10
10
  import { TransactionCategoryType, TransactionListState, TransactionListUIState } from './transactionListState';
11
11
  export declare const initialState: TransactionListState;
12
12
  export declare const parallelFetchAccountTransactionList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountId: string, accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets", period: TimePeriod, accountName?: string | undefined, cacheOverride?: any, includeSubAccountTransactions?: any], {
@@ -69,7 +69,30 @@ export declare const parallelFetchAccountTransactionList: import("@reduxjs/toolk
69
69
  classId: string;
70
70
  period: TimePeriod;
71
71
  error: ZeniAPIStatus<Record<string, unknown>>;
72
- }, "transactionList/updateTransactionListByClassFailure", never, never>, parallelFetchTransactionListByCategoryType: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionCategoryType: TransactionCategoryType, period: TimePeriod, cacheOverride?: any, minimumTransactionAmount?: Amount | undefined], {
72
+ }, "transactionList/updateTransactionListByClassFailure", never, never>, parallelFetchProjectTransactionList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountId: string, accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets", projectId: string, period: TimePeriod, cacheOverride?: any], {
73
+ accountId: string;
74
+ accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets";
75
+ projectId: string;
76
+ period: TimePeriod;
77
+ cacheOverride: any;
78
+ }, "transactionList/parallelFetchProjectTransactionList", never, never>, fetchProjectTransactionList: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountId: string, accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets", projectId: string, period: TimePeriod, cacheOverride?: any], {
79
+ accountId: string;
80
+ accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets";
81
+ projectId: string;
82
+ period: TimePeriod;
83
+ cacheOverride: any;
84
+ }, "transactionList/fetchProjectTransactionList", never, never>, updateTransactionListByProject: import("@reduxjs/toolkit").ActionCreatorWithPayload<TransactionListByProjectPayload, "transactionList/updateTransactionListByProject">, updateTransactionListByProjectUIState: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
85
+ accountId: ID;
86
+ accountType: AccountType;
87
+ projectId: ID;
88
+ uiState: TransactionListUIState;
89
+ }, "transactionList/updateTransactionListByProjectUIState">, updateTransactionListByProjectFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[accountId: string, accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets", projectId: string, period: TimePeriod, error: ZeniAPIStatus<Record<string, unknown>>], {
90
+ accountId: string;
91
+ accountType: "cash_position" | "fixed_assets" | "bank" | "credit_card" | "expenses" | "cogs" | "income" | "cash_in" | "cash_out" | "other_income" | "other_expense" | "accounts_receivable" | "other_current_assets" | "other_assets" | "accounts_payable" | "other_current_liabilities" | "long_term_liabilities" | "equity" | "current_liabilities" | "current_assets";
92
+ projectId: string;
93
+ period: TimePeriod;
94
+ error: ZeniAPIStatus<Record<string, unknown>>;
95
+ }, "transactionList/updateTransactionListByProjectFailure", never, never>, parallelFetchTransactionListByCategoryType: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionCategoryType: TransactionCategoryType, period: TimePeriod, cacheOverride?: any, minimumTransactionAmount?: Amount | undefined], {
73
96
  transactionCategoryType: TransactionCategoryType;
74
97
  period: TimePeriod;
75
98
  minimumTransactionAmount: Amount | undefined;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.updateLatestTransactionId = exports.clearTransactionList = exports.updateTransactionListUIStateByCategoryType = exports.updateTransactionsListByCategoryTypeFailure = exports.updateTransactionListByCategoryType = exports.fetchTransactionsListByCategoryType = exports.parallelFetchTransactionListByCategoryType = exports.updateTransactionListByClassFailure = exports.updateTransactionListByClassUIState = exports.updateTransactionListByClass = exports.fetchClassTransactionList = exports.parallelFetchClassTransactionList = exports.updateTransactionListByAccountUIState = exports.updateTransactionListByEntityFailure = exports.updateTransactionListByEntity = exports.fetchEntityTransactionList = exports.parallelFetchEntityTransactionList = exports.updateTransactionListByAccountFailure = exports.updateTransactionListByAccount = exports.fetchAccountTransactionList = exports.parallelFetchAccountTransactionList = exports.initialState = void 0;
4
+ exports.updateLatestTransactionId = exports.clearTransactionList = exports.updateTransactionListUIStateByCategoryType = exports.updateTransactionsListByCategoryTypeFailure = exports.updateTransactionListByCategoryType = exports.fetchTransactionsListByCategoryType = exports.parallelFetchTransactionListByCategoryType = exports.updateTransactionListByProjectFailure = exports.updateTransactionListByProjectUIState = exports.updateTransactionListByProject = exports.fetchProjectTransactionList = exports.parallelFetchProjectTransactionList = exports.updateTransactionListByClassFailure = exports.updateTransactionListByClassUIState = exports.updateTransactionListByClass = exports.fetchClassTransactionList = exports.parallelFetchClassTransactionList = exports.updateTransactionListByAccountUIState = exports.updateTransactionListByEntityFailure = exports.updateTransactionListByEntity = exports.fetchEntityTransactionList = exports.parallelFetchEntityTransactionList = exports.updateTransactionListByAccountFailure = exports.updateTransactionListByAccount = exports.fetchAccountTransactionList = exports.parallelFetchAccountTransactionList = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const timePeriod_1 = require("../../commonStateTypes/timePeriod");
7
7
  const accountPayload_1 = require("../../entity/account/accountPayload");
@@ -41,6 +41,10 @@ exports.initialState = {
41
41
  transactionListByClassKey: {},
42
42
  transactionListUIStateByClassKey: {},
43
43
  },
44
+ byProject: {
45
+ transactionListByProjectKey: {},
46
+ transactionListUIStateByProjectKey: {},
47
+ },
44
48
  };
45
49
  const transactionList = (0, toolkit_1.createSlice)({
46
50
  name: 'transactionList',
@@ -250,6 +254,64 @@ const transactionList = (0, toolkit_1.createSlice)({
250
254
  return { payload: { accountId, accountType, classId, period, error } };
251
255
  },
252
256
  },
257
+ // Transaction list by project related reducers
258
+ //
259
+ // Mirrors the by-class set; the only behavioural difference is that the
260
+ // server query param is `zeni_project_id` (post-Ayon's accounting #3984
261
+ // rename) and there's no equivalent of `include_sub_class_transactions`
262
+ // — projects don't have a sub-project hierarchy in this layout yet.
263
+ parallelFetchProjectTransactionList: {
264
+ reducer() {
265
+ // Do nothing..
266
+ },
267
+ prepare(accountId, accountType, projectId, period, cacheOverride = false) {
268
+ return {
269
+ payload: { accountId, accountType, projectId, period, cacheOverride },
270
+ };
271
+ },
272
+ },
273
+ fetchProjectTransactionList: {
274
+ reducer(draft, action) {
275
+ const key = (0, transactionListState_1.getProjectAcTranKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
276
+ if (action.payload.cacheOverride === true ||
277
+ draft.byProject.transactionListByProjectKey[key] == null ||
278
+ (draft.byProject.transactionListByProjectKey[key]?.hasValidState() ===
279
+ false &&
280
+ draft.byProject.transactionListByProjectKey[key]?.fetchState !=
281
+ 'In-Progress')) {
282
+ draft.byProject.transactionListByProjectKey[key] = {
283
+ ...transactionListState_1.initialProjectTransactionState,
284
+ fetchState: 'In-Progress',
285
+ error: undefined,
286
+ };
287
+ }
288
+ },
289
+ prepare(accountId, accountType, projectId, period, cacheOverride = false) {
290
+ return {
291
+ payload: { accountId, accountType, projectId, period, cacheOverride },
292
+ };
293
+ },
294
+ },
295
+ updateTransactionListByProject(draft, action) {
296
+ doUpdateTransactionListByProject(draft.byProject.transactionListByProjectKey, action.payload);
297
+ },
298
+ updateTransactionListByProjectUIState(draft, action) {
299
+ const key = (0, transactionListState_1.getProjectAcKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId);
300
+ draft.byProject.transactionListUIStateByProjectKey[key] = Object.assign({}, draft.byProject.transactionListUIStateByProjectKey[key], action.payload.uiState);
301
+ },
302
+ updateTransactionListByProjectFailure: {
303
+ reducer(draft, action) {
304
+ const key = (0, transactionListState_1.getProjectAcTranKey)(action.payload.accountId, action.payload.accountType, action.payload.projectId, action.payload.period);
305
+ draft.byProject.transactionListByProjectKey[key] = {
306
+ ...transactionListState_1.initialProjectTransactionState,
307
+ fetchState: 'Error',
308
+ error: action.payload.error,
309
+ };
310
+ },
311
+ prepare(accountId, accountType, projectId, period, error) {
312
+ return { payload: { accountId, accountType, projectId, period, error } };
313
+ },
314
+ },
253
315
  parallelFetchTransactionListByCategoryType: {
254
316
  reducer() {
255
317
  // Do nothing..
@@ -344,7 +406,7 @@ const transactionList = (0, toolkit_1.createSlice)({
344
406
  },
345
407
  },
346
408
  });
347
- _a = transactionList.actions, exports.parallelFetchAccountTransactionList = _a.parallelFetchAccountTransactionList, exports.fetchAccountTransactionList = _a.fetchAccountTransactionList, exports.updateTransactionListByAccount = _a.updateTransactionListByAccount, exports.updateTransactionListByAccountFailure = _a.updateTransactionListByAccountFailure, exports.parallelFetchEntityTransactionList = _a.parallelFetchEntityTransactionList, exports.fetchEntityTransactionList = _a.fetchEntityTransactionList, exports.updateTransactionListByEntity = _a.updateTransactionListByEntity, exports.updateTransactionListByEntityFailure = _a.updateTransactionListByEntityFailure, exports.updateTransactionListByAccountUIState = _a.updateTransactionListByAccountUIState, exports.parallelFetchClassTransactionList = _a.parallelFetchClassTransactionList, exports.fetchClassTransactionList = _a.fetchClassTransactionList, exports.updateTransactionListByClass = _a.updateTransactionListByClass, exports.updateTransactionListByClassUIState = _a.updateTransactionListByClassUIState, exports.updateTransactionListByClassFailure = _a.updateTransactionListByClassFailure, exports.parallelFetchTransactionListByCategoryType = _a.parallelFetchTransactionListByCategoryType, exports.fetchTransactionsListByCategoryType = _a.fetchTransactionsListByCategoryType, exports.updateTransactionListByCategoryType = _a.updateTransactionListByCategoryType, exports.updateTransactionsListByCategoryTypeFailure = _a.updateTransactionsListByCategoryTypeFailure, exports.updateTransactionListUIStateByCategoryType = _a.updateTransactionListUIStateByCategoryType, exports.clearTransactionList = _a.clearTransactionList, exports.updateLatestTransactionId = _a.updateLatestTransactionId;
409
+ _a = transactionList.actions, exports.parallelFetchAccountTransactionList = _a.parallelFetchAccountTransactionList, exports.fetchAccountTransactionList = _a.fetchAccountTransactionList, exports.updateTransactionListByAccount = _a.updateTransactionListByAccount, exports.updateTransactionListByAccountFailure = _a.updateTransactionListByAccountFailure, exports.parallelFetchEntityTransactionList = _a.parallelFetchEntityTransactionList, exports.fetchEntityTransactionList = _a.fetchEntityTransactionList, exports.updateTransactionListByEntity = _a.updateTransactionListByEntity, exports.updateTransactionListByEntityFailure = _a.updateTransactionListByEntityFailure, exports.updateTransactionListByAccountUIState = _a.updateTransactionListByAccountUIState, exports.parallelFetchClassTransactionList = _a.parallelFetchClassTransactionList, exports.fetchClassTransactionList = _a.fetchClassTransactionList, exports.updateTransactionListByClass = _a.updateTransactionListByClass, exports.updateTransactionListByClassUIState = _a.updateTransactionListByClassUIState, exports.updateTransactionListByClassFailure = _a.updateTransactionListByClassFailure, exports.parallelFetchProjectTransactionList = _a.parallelFetchProjectTransactionList, exports.fetchProjectTransactionList = _a.fetchProjectTransactionList, exports.updateTransactionListByProject = _a.updateTransactionListByProject, exports.updateTransactionListByProjectUIState = _a.updateTransactionListByProjectUIState, exports.updateTransactionListByProjectFailure = _a.updateTransactionListByProjectFailure, exports.parallelFetchTransactionListByCategoryType = _a.parallelFetchTransactionListByCategoryType, exports.fetchTransactionsListByCategoryType = _a.fetchTransactionsListByCategoryType, exports.updateTransactionListByCategoryType = _a.updateTransactionListByCategoryType, exports.updateTransactionsListByCategoryTypeFailure = _a.updateTransactionsListByCategoryTypeFailure, exports.updateTransactionListUIStateByCategoryType = _a.updateTransactionListUIStateByCategoryType, exports.clearTransactionList = _a.clearTransactionList, exports.updateLatestTransactionId = _a.updateLatestTransactionId;
348
410
  exports.default = transactionList.reducer;
349
411
  /**
350
412
  * Helper functions
@@ -394,3 +456,22 @@ function doUpdateTransactionListByClass(draft, payload) {
394
456
  transactionIDs,
395
457
  };
396
458
  }
459
+ function doUpdateTransactionListByProject(draft, payload) {
460
+ const transactionIDs = payload.account.transactions.map((transactionPaylod) => transactionPaylod.transaction_id);
461
+ const account = (0, accountPayload_1.mapAccountBasePayloadToAccountBase)(payload.account);
462
+ const projectId = payload.query.zeni_project_id;
463
+ const start = (0, timePeriod_1.toAbsoluteDay)(payload.query.start_date);
464
+ const end = (0, timePeriod_1.toAbsoluteDay)(payload.query.end_date);
465
+ const key = (0, transactionListState_1.getProjectAcTranKey)(account.accountId, account.accountType, projectId, {
466
+ start,
467
+ end,
468
+ });
469
+ draft[key] = {
470
+ ...transactionListState_1.initialProjectTransactionState,
471
+ fetchState: 'Completed',
472
+ error: undefined,
473
+ account: account,
474
+ projectId: projectId,
475
+ transactionIDs,
476
+ };
477
+ }
@@ -45,6 +45,20 @@ export interface TransactionListByClassState {
45
45
  transactionListUIStateByClassKey: Record<ClassAcKey, TransactionListUIState>;
46
46
  }
47
47
  export declare const initialClassTransactionState: ClassAccountTransactions;
48
+ export declare const getProjectAcTranKey: (accountId: ID, accountType: AccountType, projectId: ID, period: TimePeriod) => string;
49
+ export type ProjectAcTranKey = ReturnType<typeof getProjectAcTranKey>;
50
+ export declare const getProjectAcKey: (accountId: ID, accountType: AccountType, projectId: ID) => string;
51
+ type ProjectAcKey = ReturnType<typeof getProjectAcKey>;
52
+ export interface ProjectAccountTransactions extends FetchedState {
53
+ transactionIDs: ID[];
54
+ account?: AccountBase;
55
+ projectId?: ID;
56
+ }
57
+ export interface TransactionListByProjectState {
58
+ transactionListByProjectKey: Record<ProjectAcTranKey, ProjectAccountTransactions>;
59
+ transactionListUIStateByProjectKey: Record<ProjectAcKey, TransactionListUIState>;
60
+ }
61
+ export declare const initialProjectTransactionState: ProjectAccountTransactions;
48
62
  export type TransactionCategoryType = 'missingReceipts' | 'miscategorizedExpense' | 'miscategorizedIncome' | 'uncategorizedIncome' | 'uncategorizedExpense';
49
63
  export declare const getCategoryTypeTranKey: (categoryType: TransactionCategoryType, period: TimePeriod) => string;
50
64
  type CategoryTypeTranKey = ReturnType<typeof getCategoryTypeTranKey>;
@@ -59,6 +73,7 @@ export interface TransactionListState {
59
73
  byAccount: TransactionListByAccountState;
60
74
  byClass: TransactionListByClassState;
61
75
  byEntity: TransactionListByEntityState;
76
+ byProject: TransactionListByProjectState;
62
77
  byType: Record<TransactionCategoryType, TransactionListByCategoryState>;
63
78
  latestTransactionId?: TransactionID;
64
79
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialTransactionsStateByCategoryType = exports.getCategoryTypeTranKey = exports.initialClassTransactionState = exports.getClassAcKey = exports.getClassAcTranKey = exports.initialEntityTransactionState = exports.getEntityTranKey = exports.accountTransactionsInitialState = exports.getAcKey = exports.getAcTranKey = void 0;
3
+ exports.initialTransactionsStateByCategoryType = exports.getCategoryTypeTranKey = exports.initialProjectTransactionState = exports.getProjectAcKey = exports.getProjectAcTranKey = exports.initialClassTransactionState = exports.getClassAcKey = exports.getClassAcTranKey = exports.initialEntityTransactionState = exports.getEntityTranKey = exports.accountTransactionsInitialState = exports.getAcKey = exports.getAcTranKey = void 0;
4
4
  const getAcTranKey = (accountId, accountType, period) => `${accountId}-${accountType}-${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
5
5
  exports.getAcTranKey = getAcTranKey;
6
6
  const getAcKey = (accountId, accountType) => `${accountId}-${accountType}`;
@@ -38,6 +38,18 @@ exports.initialClassTransactionState = {
38
38
  return this.fetchState == 'Completed';
39
39
  },
40
40
  };
41
+ const getProjectAcTranKey = (accountId, accountType, projectId, period) => `${accountId}-${accountType}-${projectId}-${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
42
+ exports.getProjectAcTranKey = getProjectAcTranKey;
43
+ const getProjectAcKey = (accountId, accountType, projectId) => `${accountId}-${accountType}-${projectId}`;
44
+ exports.getProjectAcKey = getProjectAcKey;
45
+ exports.initialProjectTransactionState = {
46
+ transactionIDs: [],
47
+ fetchState: 'Not-Started',
48
+ error: undefined,
49
+ hasValidState() {
50
+ return this.fetchState == 'Completed';
51
+ },
52
+ };
41
53
  const getCategoryTypeTranKey = (categoryType, period) => `${categoryType}_${period.start.day}_${period.start.month}_${period.start.year}_${period.end.day}_${period.end.month}_${period.end.year}`;
42
54
  exports.getCategoryTypeTranKey = getCategoryTypeTranKey;
43
55
  exports.initialTransactionsStateByCategoryType = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.44-betaML3",
3
+ "version": "5.0.44-betaRD2",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -1,81 +0,0 @@
1
- import { concat, from, timer } from 'rxjs';
2
- import { catchError, filter, map, mergeMap } from 'rxjs/operators';
3
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
- import { toTransactionID } from '../../../../entity/transaction/payloadTypes/transactionIDPayload';
5
- import { toTransactionType } from '../../../../entity/transaction/stateTypes/transactionType';
6
- import { removeTransaction, updateTransaction, } from '../../../../entity/transaction/transactionReducer';
7
- import { isSuccessResponse } from '../../../../responsePayload';
8
- import { initializeTransactionDetailLocalData, removeTransactionDetail, } from '../../../transactionDetail/transactionDetailReducer';
9
- import { getTransactionDetailKey } from '../../../transactionDetail/transactionDetailState';
10
- import { acknowledgeTransferEntryRouteReplacement, createTransferEntry, createTransferEntryFailure, createTransferEntryReplacedTransaction, createTransferEntrySuccess, removeTransactionFromAllTabs, resetCreateTransferEntryStatus, } from '../../reducers/transactionsViewReducer';
11
- function transactionIdsAreEqual(a, b) {
12
- return a.id === b.id && a.type === b.type;
13
- }
14
- export const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(createTransferEntry.match), mergeMap((action) => {
15
- const { transactionId, creditAccountIntegrationId, debitAccountIntegrationId, memo, transactionType, sourceTransactionType, } = action.payload;
16
- const url = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`;
17
- return zeniAPI
18
- .putAndGetJSON(url, {
19
- transaction_type: transactionType,
20
- transaction_id: transactionId,
21
- to_account_integration_id: creditAccountIntegrationId,
22
- from_account_integration_id: debitAccountIntegrationId,
23
- memo,
24
- })
25
- .pipe(mergeMap((response) => {
26
- if (isSuccessResponse(response)) {
27
- const immediate = [];
28
- const previousTransactionId = {
29
- id: transactionId,
30
- type: toTransactionType(sourceTransactionType),
31
- };
32
- if (response.data?.transaction != null) {
33
- const newTransactionId = toTransactionID(response.data.transaction);
34
- const replaced = !transactionIdsAreEqual(previousTransactionId, newTransactionId);
35
- const newDetailKey = getTransactionDetailKey(newTransactionId);
36
- immediate.push(updateTransaction(newDetailKey, response.data.transaction));
37
- immediate.push(initializeTransactionDetailLocalData({
38
- transactionId: newTransactionId,
39
- vendorId: response.data.vendors?.[0]?.vendor_id,
40
- }));
41
- immediate.push(createTransferEntrySuccess(), removeTransactionFromAllTabs(transactionId), openSnackbar({
42
- messageSection: 'create_transfer_entry',
43
- messageText: 'success',
44
- type: 'success',
45
- }));
46
- if (replaced) {
47
- immediate.push(createTransferEntryReplacedTransaction(previousTransactionId, newTransactionId));
48
- }
49
- return concat(from(immediate), timer(0).pipe(map(() => resetCreateTransferEntryStatus()), mergeMap((resetAction) => replaced
50
- ? from([
51
- resetAction,
52
- removeTransaction(getTransactionDetailKey(previousTransactionId)),
53
- removeTransactionDetail(previousTransactionId),
54
- acknowledgeTransferEntryRouteReplacement(),
55
- ])
56
- : from([resetAction]))));
57
- }
58
- immediate.push(createTransferEntrySuccess(), removeTransactionFromAllTabs(transactionId), openSnackbar({
59
- messageSection: 'create_transfer_entry',
60
- messageText: 'success',
61
- type: 'success',
62
- }));
63
- return concat(from(immediate), timer(0).pipe(map(() => resetCreateTransferEntryStatus())));
64
- }
65
- return from([
66
- createTransferEntryFailure(),
67
- openSnackbar({
68
- messageSection: 'create_transfer_entry',
69
- messageText: 'failed',
70
- type: 'error',
71
- }),
72
- ]);
73
- }), catchError(() => from([
74
- createTransferEntryFailure(),
75
- openSnackbar({
76
- messageSection: 'create_transfer_entry',
77
- messageText: 'failed',
78
- type: 'error',
79
- }),
80
- ])));
81
- }));
@@ -1,25 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateAccounts } from '../../../../entity/account/accountReducer';
4
- import { isSuccessResponse } from '../../../../responsePayload';
5
- import { fetchTransferAccounts, updateTransferAccounts, updateTransferAccountsFailure, } from '../../reducers/transactionsViewReducer';
6
- const TRANSFER_ACCOUNTS_REPORT_ID = 'transfer_accounts';
7
- export const fetchTransferAccountsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchTransferAccounts.match), switchMap(() => {
8
- const queryValue = { is_only_include_transfer_accounts: true };
9
- const url = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(queryValue))}`;
10
- return zeniAPI.getJSON(url).pipe(mergeMap((response) => {
11
- if (isSuccessResponse(response) && response.data != null) {
12
- const accountIds = response.data.accounts.map((account) => account.account_id);
13
- const actions = [
14
- updateAccounts(response.data.accounts, TRANSFER_ACCOUNTS_REPORT_ID),
15
- updateTransferAccounts({ accountIds }),
16
- ];
17
- return of(...actions);
18
- }
19
- else {
20
- return of(updateTransferAccountsFailure());
21
- }
22
- }), catchError(() => {
23
- return of(updateTransferAccountsFailure());
24
- }));
25
- }));
@@ -1,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
3
- import { removeTransaction, updateTransaction } from '../../../../entity/transaction/transactionReducer';
4
- import { RootState } from '../../../../reducer';
5
- import { ZeniAPI } from '../../../../zeniAPI';
6
- import { initializeTransactionDetailLocalData, removeTransactionDetail } from '../../../transactionDetail/transactionDetailReducer';
7
- import { acknowledgeTransferEntryRouteReplacement, createTransferEntry, createTransferEntryFailure, createTransferEntryReplacedTransaction, createTransferEntrySuccess, removeTransactionFromAllTabs, resetCreateTransferEntryStatus } from '../../reducers/transactionsViewReducer';
8
- export type ActionType = ReturnType<typeof openSnackbar> | ReturnType<typeof createTransferEntry> | ReturnType<typeof createTransferEntrySuccess> | ReturnType<typeof createTransferEntryFailure> | ReturnType<typeof removeTransactionFromAllTabs> | ReturnType<typeof resetCreateTransferEntryStatus> | ReturnType<typeof createTransferEntryReplacedTransaction> | ReturnType<typeof acknowledgeTransferEntryRouteReplacement> | ReturnType<typeof updateTransaction> | ReturnType<typeof initializeTransactionDetailLocalData> | ReturnType<typeof removeTransaction> | ReturnType<typeof removeTransactionDetail>;
9
- export declare const createTransferEntryEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => import("rxjs").Observable<ActionType>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTransferEntryEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
- const transactionIDPayload_1 = require("../../../../entity/transaction/payloadTypes/transactionIDPayload");
8
- const transactionType_1 = require("../../../../entity/transaction/stateTypes/transactionType");
9
- const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
10
- const responsePayload_1 = require("../../../../responsePayload");
11
- const transactionDetailReducer_1 = require("../../../transactionDetail/transactionDetailReducer");
12
- const transactionDetailState_1 = require("../../../transactionDetail/transactionDetailState");
13
- const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
14
- function transactionIdsAreEqual(a, b) {
15
- return a.id === b.id && a.type === b.type;
16
- }
17
- const createTransferEntryEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.createTransferEntry.match), (0, operators_1.mergeMap)((action) => {
18
- const { transactionId, creditAccountIntegrationId, debitAccountIntegrationId, memo, transactionType, sourceTransactionType, } = action.payload;
19
- const url = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`;
20
- return zeniAPI
21
- .putAndGetJSON(url, {
22
- transaction_type: transactionType,
23
- transaction_id: transactionId,
24
- to_account_integration_id: creditAccountIntegrationId,
25
- from_account_integration_id: debitAccountIntegrationId,
26
- memo,
27
- })
28
- .pipe((0, operators_1.mergeMap)((response) => {
29
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
30
- const immediate = [];
31
- const previousTransactionId = {
32
- id: transactionId,
33
- type: (0, transactionType_1.toTransactionType)(sourceTransactionType),
34
- };
35
- if (response.data?.transaction != null) {
36
- const newTransactionId = (0, transactionIDPayload_1.toTransactionID)(response.data.transaction);
37
- const replaced = !transactionIdsAreEqual(previousTransactionId, newTransactionId);
38
- const newDetailKey = (0, transactionDetailState_1.getTransactionDetailKey)(newTransactionId);
39
- immediate.push((0, transactionReducer_1.updateTransaction)(newDetailKey, response.data.transaction));
40
- immediate.push((0, transactionDetailReducer_1.initializeTransactionDetailLocalData)({
41
- transactionId: newTransactionId,
42
- vendorId: response.data.vendors?.[0]?.vendor_id,
43
- }));
44
- immediate.push((0, transactionsViewReducer_1.createTransferEntrySuccess)(), (0, transactionsViewReducer_1.removeTransactionFromAllTabs)(transactionId), (0, snackbarReducer_1.openSnackbar)({
45
- messageSection: 'create_transfer_entry',
46
- messageText: 'success',
47
- type: 'success',
48
- }));
49
- if (replaced) {
50
- immediate.push((0, transactionsViewReducer_1.createTransferEntryReplacedTransaction)(previousTransactionId, newTransactionId));
51
- }
52
- return (0, rxjs_1.concat)((0, rxjs_1.from)(immediate), (0, rxjs_1.timer)(0).pipe((0, operators_1.map)(() => (0, transactionsViewReducer_1.resetCreateTransferEntryStatus)()), (0, operators_1.mergeMap)((resetAction) => replaced
53
- ? (0, rxjs_1.from)([
54
- resetAction,
55
- (0, transactionReducer_1.removeTransaction)((0, transactionDetailState_1.getTransactionDetailKey)(previousTransactionId)),
56
- (0, transactionDetailReducer_1.removeTransactionDetail)(previousTransactionId),
57
- (0, transactionsViewReducer_1.acknowledgeTransferEntryRouteReplacement)(),
58
- ])
59
- : (0, rxjs_1.from)([resetAction]))));
60
- }
61
- immediate.push((0, transactionsViewReducer_1.createTransferEntrySuccess)(), (0, transactionsViewReducer_1.removeTransactionFromAllTabs)(transactionId), (0, snackbarReducer_1.openSnackbar)({
62
- messageSection: 'create_transfer_entry',
63
- messageText: 'success',
64
- type: 'success',
65
- }));
66
- return (0, rxjs_1.concat)((0, rxjs_1.from)(immediate), (0, rxjs_1.timer)(0).pipe((0, operators_1.map)(() => (0, transactionsViewReducer_1.resetCreateTransferEntryStatus)())));
67
- }
68
- return (0, rxjs_1.from)([
69
- (0, transactionsViewReducer_1.createTransferEntryFailure)(),
70
- (0, snackbarReducer_1.openSnackbar)({
71
- messageSection: 'create_transfer_entry',
72
- messageText: 'failed',
73
- type: 'error',
74
- }),
75
- ]);
76
- }), (0, operators_1.catchError)(() => (0, rxjs_1.from)([
77
- (0, transactionsViewReducer_1.createTransferEntryFailure)(),
78
- (0, snackbarReducer_1.openSnackbar)({
79
- messageSection: 'create_transfer_entry',
80
- messageText: 'failed',
81
- type: 'error',
82
- }),
83
- ])));
84
- }));
85
- exports.createTransferEntryEpic = createTransferEntryEpic;
@@ -1,8 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateAccounts } from '../../../../entity/account/accountReducer';
4
- import { RootState } from '../../../../reducer';
5
- import { ZeniAPI } from '../../../../zeniAPI';
6
- import { fetchTransferAccounts, updateTransferAccounts, updateTransferAccountsFailure } from '../../reducers/transactionsViewReducer';
7
- export type ActionType = ReturnType<typeof fetchTransferAccounts> | ReturnType<typeof updateTransferAccounts> | ReturnType<typeof updateTransferAccountsFailure> | ReturnType<typeof updateAccounts>;
8
- export declare const fetchTransferAccountsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchTransferAccountsEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const accountReducer_1 = require("../../../../entity/account/accountReducer");
7
- const responsePayload_1 = require("../../../../responsePayload");
8
- const transactionsViewReducer_1 = require("../../reducers/transactionsViewReducer");
9
- const TRANSFER_ACCOUNTS_REPORT_ID = 'transfer_accounts';
10
- const fetchTransferAccountsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transactionsViewReducer_1.fetchTransferAccounts.match), (0, operators_1.switchMap)(() => {
11
- const queryValue = { is_only_include_transfer_accounts: true };
12
- const url = `${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(queryValue))}`;
13
- return zeniAPI.getJSON(url).pipe((0, operators_1.mergeMap)((response) => {
14
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
15
- const accountIds = response.data.accounts.map((account) => account.account_id);
16
- const actions = [
17
- (0, accountReducer_1.updateAccounts)(response.data.accounts, TRANSFER_ACCOUNTS_REPORT_ID),
18
- (0, transactionsViewReducer_1.updateTransferAccounts)({ accountIds }),
19
- ];
20
- return (0, rxjs_1.of)(...actions);
21
- }
22
- else {
23
- return (0, rxjs_1.of)((0, transactionsViewReducer_1.updateTransferAccountsFailure)());
24
- }
25
- }), (0, operators_1.catchError)(() => {
26
- return (0, rxjs_1.of)((0, transactionsViewReducer_1.updateTransferAccountsFailure)());
27
- }));
28
- }));
29
- exports.fetchTransferAccountsEpic = fetchTransferAccountsEpic;