@zeniai/client-epic-state 4.12.23 → 4.12.24

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 (115) hide show
  1. package/lib/commonStateTypes/selectorTypes/selectorTypes.d.ts +3 -1
  2. package/lib/entity/account/accountSelector.d.ts +1 -0
  3. package/lib/entity/account/accountSelector.js +13 -1
  4. package/lib/entity/class/classPayload.d.ts +1 -0
  5. package/lib/entity/class/classPayload.js +13 -29
  6. package/lib/entity/class/classState.d.ts +1 -0
  7. package/lib/entity/jeSchedules/jeScheduleHelper.d.ts +2 -0
  8. package/lib/entity/jeSchedules/jeScheduleHelper.js +7 -0
  9. package/lib/entity/jeSchedules/jeSchedulesPayload.d.ts +22 -5
  10. package/lib/entity/jeSchedules/jeSchedulesPayload.js +104 -29
  11. package/lib/entity/jeSchedules/jeSchedulesReducer.d.ts +14 -4
  12. package/lib/entity/jeSchedules/jeSchedulesReducer.js +86 -6
  13. package/lib/entity/jeSchedules/jeSchedulesSelector.d.ts +15 -3
  14. package/lib/entity/jeSchedules/jeSchedulesSelector.js +68 -5
  15. package/lib/entity/jeSchedules/jeSchedulesState.d.ts +14 -2
  16. package/lib/entity/jeSchedules/jeSchedulesTypes.d.ts +4 -2
  17. package/lib/entity/jeSchedules/jeSchedulesTypes.js +1 -0
  18. package/lib/entity/jeSchedules/updateAccruedJESchedulesEpic.d.ts +9 -0
  19. package/lib/entity/jeSchedules/updateAccruedJESchedulesEpic.js +41 -0
  20. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  21. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  22. package/lib/entity/tenant/clearAllEpic.d.ts +4 -3
  23. package/lib/entity/tenant/clearAllEpic.js +3 -0
  24. package/lib/entity/toastNotification/epic/pushToastNotificationEpic.d.ts +1 -1
  25. package/lib/entity/transaction/payloadTypes/otherTransactionPayload.d.ts +0 -2
  26. package/lib/entity/transaction/payloadTypes/scheduleTransactionPayload.d.ts +1 -1
  27. package/lib/entity/transaction/payloadTypes/transactionPayload.d.ts +3 -0
  28. package/lib/entity/transaction/payloadTypes/transactionPayload.js +7 -3
  29. package/lib/entity/transaction/payloadTypes/vendorTransactionPayload.d.ts +1 -1
  30. package/lib/entity/transaction/stateTypes/transaction.d.ts +3 -0
  31. package/lib/epic.d.ts +12 -1
  32. package/lib/epic.js +12 -1
  33. package/lib/index.d.ts +11 -5
  34. package/lib/index.js +27 -5
  35. package/lib/reducer.d.ts +3 -0
  36. package/lib/reducer.js +3 -0
  37. package/lib/view/cardPayment/epic/addCardPaymentSourceEpic.d.ts +1 -1
  38. package/lib/view/cardPayment/epic/confirmCardSetupIntentEpic.d.ts +1 -1
  39. package/lib/view/cardPayment/epic/createCardSetupIntentEpic.d.ts +1 -1
  40. package/lib/view/cardPayment/epic/fetchPaymentSourcesEpic.d.ts +1 -1
  41. package/lib/view/commonVendorView/vendorView/epics/fetchVendorEpic.js +0 -1
  42. package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
  43. package/lib/view/people/deletePersonEpic.d.ts +1 -1
  44. package/lib/view/people/invitePeopleEpic.d.ts +1 -1
  45. package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
  46. package/lib/view/people/resendInviteEpic.d.ts +1 -1
  47. package/lib/view/scheduleView/scheduleAccruedDetailView/LinkBillExpenseView/linkBillExpense.d.ts +3 -0
  48. package/lib/view/scheduleView/scheduleAccruedDetailView/LinkBillExpenseView/linkBillExpense.js +12 -0
  49. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/cancelScheduleAccruedJournalEntryEpic.d.ts +8 -0
  50. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/cancelScheduleAccruedJournalEntryEpic.js +81 -0
  51. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/createNewSchedulesAccruedEpic.d.ts +6 -0
  52. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/createNewSchedulesAccruedEpic.js +35 -0
  53. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/deleteScheduleAccruedDetailEpic.d.ts +8 -0
  54. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/deleteScheduleAccruedDetailEpic.js +79 -0
  55. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/fetchRecommendedTransactionRowIndexEpic.d.ts +7 -0
  56. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/fetchRecommendedTransactionRowIndexEpic.js +73 -0
  57. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/fetchScheduleAccruedDetailsEpic.d.ts +8 -0
  58. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/fetchScheduleAccruedDetailsEpic.js +53 -0
  59. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/fetchScheduleAccruedDetailsPageEpic.d.ts +8 -0
  60. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/fetchScheduleAccruedDetailsPageEpic.js +28 -0
  61. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/initializeScheduleAccruedDetailLocalDataEpic.d.ts +6 -0
  62. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/initializeScheduleAccruedDetailLocalDataEpic.js +37 -0
  63. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/saveScheduleAccruedDetailsEpic.d.ts +12 -0
  64. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/saveScheduleAccruedDetailsEpic.js +126 -0
  65. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/updateAmountsInScheduleAccruedDetailEpic.d.ts +6 -0
  66. package/lib/view/scheduleView/scheduleAccruedDetailView/epics/updateAmountsInScheduleAccruedDetailEpic.js +30 -0
  67. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailLocalDataHelper.d.ts +16 -0
  68. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailLocalDataHelper.js +121 -0
  69. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailPayload.d.ts +60 -0
  70. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailPayload.js +288 -0
  71. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailReducer.d.ts +83 -0
  72. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailReducer.js +363 -0
  73. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailSelector.d.ts +36 -0
  74. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailSelector.js +127 -0
  75. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailState.d.ts +45 -0
  76. package/lib/view/scheduleView/scheduleAccruedDetailView/scheduleAccruedDetailState.js +2 -0
  77. package/lib/view/scheduleView/scheduleDetailView/epics/createNewSchedulesEpic.js +1 -1
  78. package/lib/view/scheduleView/scheduleDetailView/epics/deleteScheduleDetailEpic.js +1 -1
  79. package/lib/view/scheduleView/scheduleDetailView/epics/fetchScheduleDetailsPageEpic.js +3 -1
  80. package/lib/view/scheduleView/scheduleDetailView/epics/initializeScheduleDetailLocalDataEpic.js +1 -1
  81. package/lib/view/scheduleView/scheduleDetailView/epics/markAsCompleteScheduleDetailEpic.js +1 -1
  82. package/lib/view/scheduleView/scheduleDetailView/epics/saveScheduleDetailsEpic.d.ts +2 -2
  83. package/lib/view/scheduleView/scheduleDetailView/epics/saveScheduleDetailsEpic.js +1 -1
  84. package/lib/view/scheduleView/scheduleDetailView/epics/updateAmountsInScheduleDetailEpic.js +1 -1
  85. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailLocalDataHelper.js +2 -0
  86. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailPayload.d.ts +11 -5
  87. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailPayload.js +66 -2
  88. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailReducer.d.ts +2 -5
  89. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailReducer.js +2 -17
  90. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailSelector.js +7 -3
  91. package/lib/view/scheduleView/scheduleDetailView/scheduleDetailState.d.ts +3 -2
  92. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.d.ts +8 -0
  93. package/lib/view/scheduleView/scheduleListView/epics/fetchAccruedScheduleListEpic.js +52 -0
  94. package/lib/view/scheduleView/scheduleListView/epics/fetchDownloadSchedulesEpic.js +7 -1
  95. package/lib/view/scheduleView/scheduleListView/epics/fetchScheduleListEpic.js +7 -1
  96. package/lib/view/scheduleView/scheduleListView/scheduleListHelper.d.ts +33 -2
  97. package/lib/view/scheduleView/scheduleListView/scheduleListHelper.js +117 -1
  98. package/lib/view/scheduleView/scheduleListView/scheduleListPayload.d.ts +6 -1
  99. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.d.ts +32 -4
  100. package/lib/view/scheduleView/scheduleListView/scheduleListReducer.js +207 -69
  101. package/lib/view/scheduleView/scheduleListView/scheduleListSelector.d.ts +23 -1
  102. package/lib/view/scheduleView/scheduleListView/scheduleListSelector.js +176 -5
  103. package/lib/view/scheduleView/scheduleListView/scheduleListState.d.ts +15 -3
  104. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.d.ts +1 -1
  105. package/lib/view/scheduleView/scheduleListView/scheduleListTypes.js +2 -0
  106. package/lib/view/settingsView/epic/saveNotificationSettingsEpic.d.ts +1 -1
  107. package/lib/view/tagView/epics/createTagEpic.d.ts +1 -1
  108. package/lib/view/tagView/epics/deleteTagEpic.d.ts +1 -1
  109. package/lib/view/vendorList/vendorListSelector.d.ts +1 -1
  110. package/lib/view/vendorList/vendorListSelector.js +1 -0
  111. package/lib/view/vendorTabView/fetchVendorTabViewEpic.d.ts +2 -2
  112. package/lib/view/vendorTabView/fetchVendorTabViewEpic.js +11 -1
  113. package/lib/view/vendorTabView/vendorTabViewReducer.d.ts +2 -0
  114. package/lib/view/vendorTabView/vendorTabViewReducer.js +2 -1
  115. package/package.json +1 -1
@@ -2,8 +2,9 @@ import { AccountGroupReport } from '../../entity/accountGroup/accountGroupSelect
2
2
  import { AccountReport } from '../../entity/account/accountSelector';
3
3
  import { COABalancesSlice } from '../coaBalance/coaBalancesFilter';
4
4
  export declare type TransactionsOrder = 'descending_amount' | 'ascending_amount' | 'descending_transaction_date' | 'ascending_transaction_date';
5
+ declare type ScheduleOrder = 'descending_schedule_date' | 'ascending_schedule_date';
5
6
  export declare type COABalancesSliceOrder = 'last_balance_descending' | 'last_balance_ascending' | 'balances_total_descending' | 'balances_total_ascending';
6
- export declare type EntityOrder = TransactionsOrder | COABalancesSliceOrder | 'default';
7
+ export declare type EntityOrder = ScheduleOrder | TransactionsOrder | COABalancesSliceOrder | 'default';
7
8
  export interface Section extends COABalancesSlice {
8
9
  itemOrder: EntityOrder;
9
10
  accountGroupsOrdered: AccountGroupReport[];
@@ -15,3 +16,4 @@ export interface SectionWithAccountOnly extends COABalancesSlice {
15
16
  }
16
17
  export interface CalculatedSection extends COABalancesSlice {
17
18
  }
19
+ export {};
@@ -110,3 +110,4 @@ export declare const getAccountsOrdered: (filter: COABalancesFilter, accountStat
110
110
  }[];
111
111
  export declare const getAccountsByType: (accountState: AccountState, accountTypes: AccountType[]) => Partial<Record<AccountType, Account[]>>;
112
112
  export declare const getAccountIdsForTypes: (accountState: AccountState, accountTypes: AccountType[]) => ID[];
113
+ export declare const getAccountIdsForLabels: (accountState: AccountState, labels: string[]) => ID[];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getAccountIdsForTypes = exports.getAccountsByType = exports.getAccountsOrdered = exports.getAccountWithBalance = exports.getAccount = exports.getAccountBase = void 0;
6
+ exports.getAccountIdsForLabels = exports.getAccountIdsForTypes = exports.getAccountsByType = exports.getAccountsOrdered = exports.getAccountWithBalance = exports.getAccount = exports.getAccountBase = void 0;
7
7
  const flatMap_1 = __importDefault(require("lodash/flatMap"));
8
8
  const accountState_1 = require("./accountState");
9
9
  const coaBalance_1 = require("../../commonStateTypes/coaBalance/coaBalance");
@@ -170,3 +170,15 @@ const getAccountIdsForTypes = (accountState, accountTypes) => {
170
170
  return allAccountIdsForTypes;
171
171
  };
172
172
  exports.getAccountIdsForTypes = getAccountIdsForTypes;
173
+ const getAccountIdsForLabels = (accountState, labels) => {
174
+ const allAccountIdsForLabels = [];
175
+ Object.entries(accountState.accountsByKey).forEach(([, account]) => {
176
+ for (let i = 0; i < account.labels.length; i++) {
177
+ if (labels.includes(account.labels[i])) {
178
+ allAccountIdsForLabels.push(account.accountId);
179
+ }
180
+ }
181
+ });
182
+ return allAccountIdsForLabels;
183
+ };
184
+ exports.getAccountIdsForLabels = getAccountIdsForLabels;
@@ -6,6 +6,7 @@ export interface ClassBasePayload {
6
6
  accounting_class_id: string;
7
7
  accounting_class_name: string;
8
8
  qbo_id?: string | null;
9
+ labels?: string[];
9
10
  fully_qualified_accounting_class_name?: string;
10
11
  accounting_class_number?: string | null;
11
12
  }
@@ -6,37 +6,27 @@ const classState_1 = require("./classState");
6
6
  function mapClassBasePayloadToClass(payload, reportId, classesViewParentId) {
7
7
  var _a;
8
8
  const key = (0, classState_1.getClassKey)(reportId, payload.accounting_class_id, classesViewParentId);
9
- return {
10
- key,
11
- classesViewParentId,
12
- accountIds: [],
13
- classId: payload.accounting_class_id,
14
- className: payload.accounting_class_name,
15
- qboId: payload.qbo_id != null && payload.qbo_id.length > 0
9
+ return Object.assign({ key,
10
+ classesViewParentId, accountIds: [], classId: payload.accounting_class_id, className: payload.accounting_class_name, qboId: payload.qbo_id != null && payload.qbo_id.length > 0
16
11
  ? payload.qbo_id
17
- : undefined,
18
- fullyQualifiedAccountingClassName: (_a = payload.fully_qualified_accounting_class_name) !== null && _a !== void 0 ? _a : '',
19
- accountingClassNumber: payload.accounting_class_number != null &&
12
+ : undefined, fullyQualifiedAccountingClassName: (_a = payload.fully_qualified_accounting_class_name) !== null && _a !== void 0 ? _a : '', accountingClassNumber: payload.accounting_class_number != null &&
20
13
  payload.accounting_class_number.length > 0
21
14
  ? payload.accounting_class_number
22
- : undefined,
23
- };
15
+ : undefined }, (payload.labels != null && payload.labels.length > 0
16
+ ? { labels: payload.labels }
17
+ : {}));
24
18
  }
25
19
  exports.mapClassBasePayloadToClass = mapClassBasePayloadToClass;
26
20
  function mapClassBasePayloadToClassBase(payload) {
27
21
  var _a, _b;
28
- return {
29
- classId: (_a = payload.accounting_class_id) !== null && _a !== void 0 ? _a : '',
30
- className: 'accounting_class_name' in payload ? payload.accounting_class_name : '',
31
- qboId: payload.qbo_id != null && payload.qbo_id.length > 0
22
+ return Object.assign({ classId: (_a = payload.accounting_class_id) !== null && _a !== void 0 ? _a : '', className: 'accounting_class_name' in payload ? payload.accounting_class_name : '', qboId: payload.qbo_id != null && payload.qbo_id.length > 0
32
23
  ? payload.qbo_id
33
- : undefined,
34
- fullyQualifiedAccountingClassName: (_b = payload.fully_qualified_accounting_class_name) !== null && _b !== void 0 ? _b : '',
35
- accountingClassNumber: payload.accounting_class_number != null &&
24
+ : undefined, fullyQualifiedAccountingClassName: (_b = payload.fully_qualified_accounting_class_name) !== null && _b !== void 0 ? _b : '', accountingClassNumber: payload.accounting_class_number != null &&
36
25
  payload.accounting_class_number.length > 0
37
26
  ? payload.accounting_class_number
38
- : undefined,
39
- };
27
+ : undefined }, (payload.labels != null && payload.labels.length > 0
28
+ ? { labels: payload.labels }
29
+ : {}));
40
30
  }
41
31
  exports.mapClassBasePayloadToClassBase = mapClassBasePayloadToClassBase;
42
32
  function mapRecommendedClassBasePayloadToRecommendedClassBase(payload) {
@@ -54,18 +44,12 @@ function mapRecommendedClassBasePayloadToRecommendedClassBase(payload) {
54
44
  exports.mapRecommendedClassBasePayloadToRecommendedClassBase = mapRecommendedClassBasePayloadToRecommendedClassBase;
55
45
  const toClassBasePayload = (cl) => {
56
46
  var _a, _b, _c, _d, _e;
57
- return ({
58
- accounting_class_id: (_a = cl === null || cl === void 0 ? void 0 : cl.classId) !== null && _a !== void 0 ? _a : '',
59
- accounting_class_name: (_b = cl === null || cl === void 0 ? void 0 : cl.className) !== null && _b !== void 0 ? _b : '',
60
- qbo_id: (_c = cl === null || cl === void 0 ? void 0 : cl.qboId) !== null && _c !== void 0 ? _c : null,
61
- fully_qualified_accounting_class_name: (_d = cl === null || cl === void 0 ? void 0 : cl.fullyQualifiedAccountingClassName) !== null && _d !== void 0 ? _d : '',
62
- accounting_class_number: (_e = cl === null || cl === void 0 ? void 0 : cl.accountingClassNumber) !== null && _e !== void 0 ? _e : null,
63
- });
47
+ return (Object.assign({ accounting_class_id: (_a = cl === null || cl === void 0 ? void 0 : cl.classId) !== null && _a !== void 0 ? _a : '', accounting_class_name: (_b = cl === null || cl === void 0 ? void 0 : cl.className) !== null && _b !== void 0 ? _b : '', qbo_id: (_c = cl === null || cl === void 0 ? void 0 : cl.qboId) !== null && _c !== void 0 ? _c : null, fully_qualified_accounting_class_name: (_d = cl === null || cl === void 0 ? void 0 : cl.fullyQualifiedAccountingClassName) !== null && _d !== void 0 ? _d : '', accounting_class_number: (_e = cl === null || cl === void 0 ? void 0 : cl.accountingClassNumber) !== null && _e !== void 0 ? _e : null }, ((cl === null || cl === void 0 ? void 0 : cl.labels) != null && cl.labels.length > 0 ? { labels: cl.labels } : {})));
64
48
  };
65
49
  exports.toClassBasePayload = toClassBasePayload;
66
50
  const toRecommendedClassBasePayload = (cl) => {
67
51
  var _a, _b, _c, _d, _e;
68
- return Object.assign({ accounting_class_id: (_a = cl === null || cl === void 0 ? void 0 : cl.classId) !== null && _a !== void 0 ? _a : '', accounting_class_name: (_b = cl === null || cl === void 0 ? void 0 : cl.className) !== null && _b !== void 0 ? _b : '', qbo_id: (_c = cl === null || cl === void 0 ? void 0 : cl.qboId) !== null && _c !== void 0 ? _c : null, fully_qualified_accounting_class_name: (_d = cl === null || cl === void 0 ? void 0 : cl.fullyQualifiedAccountingClassName) !== null && _d !== void 0 ? _d : '', accounting_class_number: (_e = cl === null || cl === void 0 ? void 0 : cl.accountingClassNumber) !== null && _e !== void 0 ? _e : null }, (0, recommendationPayload_1.toRecommendationBasePayload)(cl));
52
+ return Object.assign(Object.assign({ accounting_class_id: (_a = cl === null || cl === void 0 ? void 0 : cl.classId) !== null && _a !== void 0 ? _a : '', accounting_class_name: (_b = cl === null || cl === void 0 ? void 0 : cl.className) !== null && _b !== void 0 ? _b : '', qbo_id: (_c = cl === null || cl === void 0 ? void 0 : cl.qboId) !== null && _c !== void 0 ? _c : null, fully_qualified_accounting_class_name: (_d = cl === null || cl === void 0 ? void 0 : cl.fullyQualifiedAccountingClassName) !== null && _d !== void 0 ? _d : '', accounting_class_number: (_e = cl === null || cl === void 0 ? void 0 : cl.accountingClassNumber) !== null && _e !== void 0 ? _e : null }, ((cl === null || cl === void 0 ? void 0 : cl.labels) != null && cl.labels.length > 0 ? { labels: cl.labels } : {})), (0, recommendationPayload_1.toRecommendationBasePayload)(cl));
69
53
  };
70
54
  exports.toRecommendedClassBasePayload = toRecommendedClassBasePayload;
71
55
  const toClassMetadata = (payload) => (Object.assign(Object.assign({}, mapClassBasePayloadToClassBase(payload)), { parentClassId: payload.parent_accounting_class_id != null
@@ -8,6 +8,7 @@ export interface ClassBase {
8
8
  classId: ID;
9
9
  className: string;
10
10
  fullyQualifiedAccountingClassName: string;
11
+ labels?: string[];
11
12
  qboId?: ID;
12
13
  accountingClassNumber?: string;
13
14
  }
@@ -0,0 +1,2 @@
1
+ import { JEAccruedScheduledTransactionPayload } from './jeSchedulesPayload';
2
+ export declare function generateJEScheduleKey(payload: JEAccruedScheduledTransactionPayload): `${string}_${string}`;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateJEScheduleKey = void 0;
4
+ function generateJEScheduleKey(payload) {
5
+ return `${payload.je_schedule_id}_${payload.je_schedule_type}`;
6
+ }
7
+ exports.generateJEScheduleKey = generateJEScheduleKey;
@@ -3,13 +3,15 @@ import { ID } from '../../commonStateTypes/common';
3
3
  import { AccountPayload } from '../account/accountPayload';
4
4
  import { ClassBasePayload } from '../class/classPayload';
5
5
  import { ScheduleTransactionPayload } from '../transaction/payloadTypes/scheduleTransactionPayload';
6
+ import { TransactionIDPayload } from '../transaction/payloadTypes/transactionIDPayload';
6
7
  import { TransactionCategory } from '../transaction/stateTypes/transactionType';
7
8
  import { UserPayload } from '../user/userPayload';
8
9
  import { VendorPayload } from '../vendor/vendorPayload';
9
- import { JEScheduledTransactionState, ScheduledJournalEntryState } from './jeSchedulesState';
10
- import { JEScheduleKey } from './jeSchedulesTypes';
10
+ import { JEScheduledTransactionState, JEAccruedScheduledTransactionState, ScheduledJournalEntryState } from './jeSchedulesState';
11
+ import { JEScheduleKey, JEScheduleTransactionKey } from './jeSchedulesTypes';
11
12
  export interface JEScheduleOtherAttributesPayload {
12
13
  asset_id?: string | null;
14
+ starting_balance?: number | null;
13
15
  }
14
16
  export interface JEScheduledTransactionPayload {
15
17
  status: StatusCodeWithLabelPayload;
@@ -36,12 +38,24 @@ export interface JEScheduledTransactionPayload {
36
38
  je_debit_accounting_class_id: string | null;
37
39
  other_attributes: JEScheduleOtherAttributesPayload;
38
40
  }
41
+ export interface JEAccruedScheduledTransactionPayload extends Omit<JEScheduledTransactionPayload, 'base_transaction' | 'je_schedule_id' | 'je_schedule_type'> {
42
+ je_schedule_id: ID;
43
+ je_schedule_type: string;
44
+ recurring_amount: number;
45
+ create_time: string;
46
+ memo: string;
47
+ }
39
48
  export interface ScheduledJournalEntryPayload {
40
49
  status: StatusCodeWithLabelPayload;
41
50
  transaction_memo: string;
42
51
  third_party_id: string | null;
52
+ reversal_third_party_id: string | null;
53
+ reversal_transaction_details?: TransactionIDPayload | null;
54
+ is_bill_linked?: boolean | null;
55
+ actual_reversal_post_date?: string | null;
43
56
  recommended_transaction_id: string | null;
44
57
  transaction_id: string | null;
58
+ reversal_transaction_id: string | null;
45
59
  expected_post_date: string;
46
60
  je_schedule_id?: string | null;
47
61
  scheduled_journal_entry_id?: string | null;
@@ -53,7 +67,10 @@ export interface ScheduledJournalEntryPayload {
53
67
  create_time: string | null;
54
68
  }
55
69
  export declare function toScheduledJournalEntryState(payload: ScheduledJournalEntryPayload, currency_code: string, currency_symbol: string): ScheduledJournalEntryState;
56
- export declare function toJEAccountPayload(payload: JEScheduledTransactionPayload, type: TransactionCategory): AccountPayload | undefined;
57
- export declare function toJEClassPayload(payload: JEScheduledTransactionPayload, type: TransactionCategory): ClassBasePayload | undefined;
58
- export declare function getTransactionDetailKeyPayload(payload: ScheduleTransactionPayload): JEScheduleKey;
70
+ export declare function toJEAccountPayload(payload: JEScheduledTransactionPayload | JEAccruedScheduledTransactionPayload, type: TransactionCategory): AccountPayload | undefined;
71
+ export declare function toJEAccruedAccountPayload(payload: JEScheduledTransactionPayload | JEAccruedScheduledTransactionPayload, type: TransactionCategory): AccountPayload | undefined;
72
+ export declare function toJEClassPayload(payload: JEScheduledTransactionPayload | JEAccruedScheduledTransactionPayload, type: TransactionCategory): ClassBasePayload | undefined;
73
+ export declare function getTransactionDetailKeyPayload(payload: ScheduleTransactionPayload): JEScheduleTransactionKey;
74
+ export declare function getJEScheduleKey(payload: JEAccruedScheduledTransactionPayload): JEScheduleKey;
59
75
  export declare function toJEScheduledTransaction(payload: JEScheduledTransactionPayload): JEScheduledTransactionState;
76
+ export declare function toJEAccruedScheduledTransaction(payload: JEAccruedScheduledTransactionPayload): JEAccruedScheduledTransactionState;
@@ -1,51 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toJEScheduledTransaction = exports.getTransactionDetailKeyPayload = exports.toJEClassPayload = exports.toJEAccountPayload = exports.toScheduledJournalEntryState = void 0;
3
+ exports.toJEAccruedScheduledTransaction = exports.toJEScheduledTransaction = exports.getJEScheduleKey = exports.getTransactionDetailKeyPayload = exports.toJEClassPayload = exports.toJEAccruedAccountPayload = exports.toJEAccountPayload = exports.toScheduledJournalEntryState = void 0;
4
4
  const amount_1 = require("../../commonStateTypes/amount");
5
5
  const timePeriod_1 = require("../../commonStateTypes/timePeriod");
6
6
  const transactionDetailState_1 = require("../../view/transactionDetail/transactionDetailState");
7
7
  const zeniDayJS_1 = require("../../zeniDayJS");
8
8
  const transactionIDPayload_1 = require("../transaction/payloadTypes/transactionIDPayload");
9
+ const jeScheduleHelper_1 = require("./jeScheduleHelper");
9
10
  const jeSchedulesTypes_1 = require("./jeSchedulesTypes");
10
11
  function toScheduledJournalEntryState(payload, currency_code, currency_symbol) {
11
- var _a, _b, _c, _d;
12
- return {
13
- status: {
12
+ var _a, _b, _c, _d, _e, _f;
13
+ return Object.assign(Object.assign({ status: {
14
14
  code: (0, jeSchedulesTypes_1.toScheduleJournalEntryStatusCodeType)(payload.status.code),
15
15
  label: payload.status.label,
16
- },
17
- memo: (_a = payload.transaction_memo) !== null && _a !== void 0 ? _a : '',
18
- thirdPartyID: payload.third_party_id != null && payload.third_party_id.length > 0
16
+ }, memo: (_a = payload.transaction_memo) !== null && _a !== void 0 ? _a : '', thirdPartyID: payload.third_party_id != null && payload.third_party_id.length > 0
19
17
  ? payload.third_party_id
20
- : undefined,
21
- transactionID: payload.transaction_id != null && payload.transaction_id.length > 0
18
+ : undefined, reversalThirdPartyID: payload.reversal_third_party_id != null
19
+ ? payload.reversal_third_party_id
20
+ : undefined, actualReversalPostDate: payload.actual_reversal_post_date != null
21
+ ? (0, zeniDayJS_1.date)(payload.actual_reversal_post_date)
22
+ : undefined }, (payload.reversal_transaction_details != null && {
23
+ reversalTransactionDetails: (0, transactionIDPayload_1.toTransactionID)({
24
+ transaction_id: payload.reversal_transaction_details.transaction_id,
25
+ transaction_type: (_c = (_b = payload.reversal_transaction_details) === null || _b === void 0 ? void 0 : _b.transaction_type) !== null && _c !== void 0 ? _c : 'journal_entry',
26
+ }),
27
+ })), { transactionID: payload.transaction_id != null && payload.transaction_id.length > 0
22
28
  ? payload.transaction_id
23
- : undefined,
24
- recommendedTransactionID: payload.recommended_transaction_id != null
29
+ : undefined, reversalTransactionID: payload.reversal_transaction_id != null &&
30
+ payload.reversal_transaction_id.length > 0
31
+ ? payload.reversal_transaction_id
32
+ : undefined, recommendedTransactionID: payload.recommended_transaction_id != null
25
33
  ? (0, transactionIDPayload_1.toTransactionID)({
26
34
  transaction_id: payload.recommended_transaction_id,
27
35
  transaction_type: 'journal_entry',
28
36
  })
29
- : undefined,
30
- expectedPostDate: (0, zeniDayJS_1.date)(payload.expected_post_date),
31
- actualPostDate: payload.actual_post_date != null
37
+ : undefined, expectedPostDate: (0, zeniDayJS_1.date)(payload.expected_post_date), actualPostDate: payload.actual_post_date != null
32
38
  ? (0, zeniDayJS_1.date)(payload.actual_post_date)
33
- : undefined,
34
- amount: payload.amount != null
39
+ : undefined, amount: payload.amount != null
35
40
  ? (0, amount_1.toAmount)(payload.amount, currency_code, currency_symbol)
36
- : (0, amount_1.toAmount)(0, currency_code, currency_symbol),
37
- runningBalance: payload.balance != null
41
+ : (0, amount_1.toAmount)(0, currency_code, currency_symbol), runningBalance: payload.balance != null
38
42
  ? (0, amount_1.toAmount)(payload.balance, currency_code, currency_symbol)
39
- : (0, amount_1.toAmount)(0, currency_code, currency_symbol),
40
- scheduledJournalEntryID: (_b = payload.scheduled_journal_entry_id) !== null && _b !== void 0 ? _b : '',
41
- jeScheduleId: (_c = payload.je_schedule_id) !== null && _c !== void 0 ? _c : '',
42
- isPlatformGenerated: (_d = payload.is_platform_generated) !== null && _d !== void 0 ? _d : undefined,
43
- createTime: payload.create_time != null ? (0, zeniDayJS_1.date)(payload.create_time) : undefined,
44
- updateTime: payload.update_time != null ? (0, zeniDayJS_1.date)(payload.update_time) : undefined,
45
- syncToken: payload.update_time != null ? payload.update_time : undefined,
46
- currencyCode: currency_code,
47
- currencySymbol: currency_symbol,
48
- };
43
+ : (0, amount_1.toAmount)(0, currency_code, currency_symbol), scheduledJournalEntryID: (_d = payload.scheduled_journal_entry_id) !== null && _d !== void 0 ? _d : '', jeScheduleId: (_e = payload.je_schedule_id) !== null && _e !== void 0 ? _e : '', isPlatformGenerated: (_f = payload.is_platform_generated) !== null && _f !== void 0 ? _f : undefined, createTime: payload.create_time != null ? (0, zeniDayJS_1.date)(payload.create_time) : undefined, updateTime: payload.update_time != null ? (0, zeniDayJS_1.date)(payload.update_time) : undefined, syncToken: payload.update_time != null ? payload.update_time : undefined, currencyCode: currency_code, currencySymbol: currency_symbol });
49
44
  }
50
45
  exports.toScheduledJournalEntryState = toScheduledJournalEntryState;
51
46
  function toJEAccountPayload(payload, type) {
@@ -70,6 +65,28 @@ function toJEAccountPayload(payload, type) {
70
65
  }
71
66
  }
72
67
  exports.toJEAccountPayload = toJEAccountPayload;
68
+ function toJEAccruedAccountPayload(payload, type) {
69
+ var _a, _b;
70
+ if (type === 'debit') {
71
+ return payload.je_debit_account_id != null
72
+ ? {
73
+ account_name: (_a = payload.je_debit_account_name) !== null && _a !== void 0 ? _a : '',
74
+ account_id: payload.je_debit_account_id,
75
+ labels: [],
76
+ }
77
+ : undefined;
78
+ }
79
+ else {
80
+ return payload.je_credit_account_id != null
81
+ ? {
82
+ account_name: (_b = payload.je_credit_account_name) !== null && _b !== void 0 ? _b : '',
83
+ account_id: payload.je_credit_account_id,
84
+ labels: ['accrued_expenses'], // special case for Accrued Expenses
85
+ }
86
+ : undefined;
87
+ }
88
+ }
89
+ exports.toJEAccruedAccountPayload = toJEAccruedAccountPayload;
73
90
  function toJEClassPayload(payload, type) {
74
91
  var _a, _b;
75
92
  if (type === 'debit') {
@@ -95,6 +112,10 @@ function getTransactionDetailKeyPayload(payload) {
95
112
  return (0, transactionDetailState_1.getZeniTransactionDetailKey)(transactionId);
96
113
  }
97
114
  exports.getTransactionDetailKeyPayload = getTransactionDetailKeyPayload;
115
+ function getJEScheduleKey(payload) {
116
+ return (0, jeScheduleHelper_1.generateJEScheduleKey)(payload);
117
+ }
118
+ exports.getJEScheduleKey = getJEScheduleKey;
98
119
  function toJEScheduleOtherAttributes(payload) {
99
120
  var _a;
100
121
  return {
@@ -114,7 +135,7 @@ function toJEScheduledTransaction(payload) {
114
135
  startDate: payload.start_date != null ? (0, zeniDayJS_1.date)(payload.start_date) : undefined,
115
136
  endDate: payload.end_date != null ? (0, zeniDayJS_1.date)(payload.end_date) : undefined,
116
137
  period: payload.period != null ? Number(payload.period) : undefined,
117
- updatedByUserID: payload.updated_by != null ? payload.updated_by.user_id : undefined,
138
+ updatedByUserID: payload.updated_by.user_id,
118
139
  balanceAsOfToday: (_b = payload.balance) !== null && _b !== void 0 ? _b : undefined,
119
140
  updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
120
141
  jeCredit: {
@@ -143,3 +164,57 @@ function toJEScheduledTransaction(payload) {
143
164
  };
144
165
  }
145
166
  exports.toJEScheduledTransaction = toJEScheduledTransaction;
167
+ function toJEAccruedScheduledTransaction(payload) {
168
+ var _a, _b, _c, _d, _e, _f, _g, _h;
169
+ return {
170
+ jeScheduleId: payload.je_schedule_id,
171
+ status: {
172
+ code: (0, jeSchedulesTypes_1.toScheduleStatusCodeType)(payload.status.code),
173
+ label: payload.status.label,
174
+ },
175
+ vendorId: payload.vendor.vendor_id,
176
+ recurringAmount: {
177
+ amount: payload.recurring_amount,
178
+ currencyCode: 'USD',
179
+ currencySymbol: '$',
180
+ },
181
+ otherAttributes: {
182
+ startingBalance: ((_a = payload.other_attributes) === null || _a === void 0 ? void 0 : _a.starting_balance) != null
183
+ ? {
184
+ amount: (_c = (_b = payload.other_attributes) === null || _b === void 0 ? void 0 : _b.starting_balance) !== null && _c !== void 0 ? _c : 0,
185
+ currencyCode: 'USD',
186
+ currencySymbol: '$',
187
+ }
188
+ : undefined,
189
+ },
190
+ memo: payload.memo,
191
+ startDate: payload.start_date != null ? (0, zeniDayJS_1.date)(payload.start_date) : undefined,
192
+ endDate: payload.end_date != null ? (0, zeniDayJS_1.date)(payload.end_date) : undefined,
193
+ period: payload.period != null ? Number(payload.period) : undefined,
194
+ updatedByUserID: payload.updated_by.user_id,
195
+ balanceAsOfToday: (_d = payload.balance) !== null && _d !== void 0 ? _d : undefined,
196
+ updatedAt: payload.updated_at != null ? (0, zeniDayJS_1.date)(payload.updated_at) : undefined,
197
+ jeCredit: {
198
+ accountId: (_e = payload.je_credit_account_id) !== null && _e !== void 0 ? _e : undefined,
199
+ accountingClassId: (_f = payload.je_credit_accounting_class_id) !== null && _f !== void 0 ? _f : undefined,
200
+ },
201
+ jeDebit: {
202
+ accountId: (_g = payload.je_debit_account_id) !== null && _g !== void 0 ? _g : undefined,
203
+ accountingClassId: (_h = payload.je_debit_accounting_class_id) !== null && _h !== void 0 ? _h : undefined,
204
+ },
205
+ currencyCode: payload.currency_code,
206
+ currencySymbol: payload.currency_symbol,
207
+ dayOfPostingDate: payload.posting_date != null &&
208
+ payload.posting_date >= timePeriod_1.MIN_SCHEDULE_DAY_OF_MONTH &&
209
+ payload.posting_date <= timePeriod_1.MAX_SCHEDULE_DAY_OF_MONTH
210
+ ? (0, timePeriod_1.toScheduleDaysOfMonth)(payload.posting_date)
211
+ : undefined,
212
+ lastDayOfMonth: payload.posting_date != null &&
213
+ payload.posting_date === timePeriod_1.LAST_SCHEDULE_DAY_OF_MONTH
214
+ ? true
215
+ : undefined,
216
+ scheduledJournalEntry: [],
217
+ createTime: (0, zeniDayJS_1.date)(payload.create_time),
218
+ };
219
+ }
220
+ exports.toJEAccruedScheduledTransaction = toJEAccruedScheduledTransaction;
@@ -1,17 +1,27 @@
1
1
  import { JESchedulesState } from './jeSchedulesState';
2
- import { JEScheduledTransactionPayload, ScheduledJournalEntryPayload } from './jeSchedulesPayload';
2
+ import { JEScheduledTransactionPayload, ScheduledJournalEntryPayload, JEAccruedScheduledTransactionPayload } from './jeSchedulesPayload';
3
3
  import { UpdateType } from '../../commonStateTypes/common';
4
4
  export declare const initialState: JESchedulesState;
5
5
  export declare const updateJESchedules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeSchedulesTransactionsPayload: JEScheduledTransactionPayload[]], {
6
6
  jeSchedulesTransactionsPayload: JEScheduledTransactionPayload[];
7
+ }, string, never, never>, updateAccruedJESchedules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeAccruedSchedulesTransactionsPayload: JEAccruedScheduledTransactionPayload[]], {
8
+ jeAccruedSchedulesTransactionsPayload: JEAccruedScheduledTransactionPayload[];
7
9
  }, string, never, never>, updateJEScheduledTransaction: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
8
10
  jeSchedulesTransactionsPayload: JEScheduledTransactionPayload[];
11
+ }, string>, updateAccruedJEScheduledTransaction: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
12
+ jeAccruedSchedulesTransactionsPayload: JEAccruedScheduledTransactionPayload[];
9
13
  }, string>, updateJESchedulesDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeSchedulesPayload: JEScheduledTransactionPayload[], scheduledJEntriesPayload?: ScheduledJournalEntryPayload[] | undefined, updateType?: UpdateType | undefined], {
10
14
  jeSchedulesPayload: JEScheduledTransactionPayload[];
11
15
  scheduledJEntriesPayload: ScheduledJournalEntryPayload[] | undefined;
12
16
  updateType: UpdateType;
13
- }, string, never, never>, deleteJESchedulesDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleKey: `${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`], {
14
- jeScheduleKey: `${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`;
15
- }, string, never, never>, clearAllJEScheduleTransactions: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
17
+ }, string, never, never>, updateAccruedJESchedulesDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeSchedulesPayload: JEAccruedScheduledTransactionPayload[], scheduledJEntriesPayload?: ScheduledJournalEntryPayload[] | undefined, updateType?: UpdateType | undefined], {
18
+ jeSchedulesPayload: JEAccruedScheduledTransactionPayload[];
19
+ scheduledJEntriesPayload: ScheduledJournalEntryPayload[] | undefined;
20
+ updateType: UpdateType;
21
+ }, string, never, never>, deleteJESchedulesDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[jeScheduleTransactionKey: `${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`], {
22
+ jeScheduleTransactionKey: `${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`;
23
+ }, string, never, never>, deleteAccruedJESchedulesDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[JEScheduleKey: `${string}_${string}`], {
24
+ JEScheduleKey: `${string}_${string}`;
25
+ }, string, never, never>, clearAllAccruedJESchedules: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, clearAllJEScheduleTransactions: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
16
26
  declare const _default: import("@reduxjs/toolkit").Reducer<JESchedulesState, import("@reduxjs/toolkit").AnyAction>;
17
27
  export default _default;
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  var _a;
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.clearAllJEScheduleTransactions = exports.deleteJESchedulesDetails = exports.updateJESchedulesDetails = exports.updateJEScheduledTransaction = exports.updateJESchedules = exports.initialState = void 0;
7
+ exports.clearAllJEScheduleTransactions = exports.clearAllAccruedJESchedules = exports.deleteAccruedJESchedulesDetails = exports.deleteJESchedulesDetails = exports.updateAccruedJESchedulesDetails = exports.updateJESchedulesDetails = exports.updateAccruedJEScheduledTransaction = exports.updateJEScheduledTransaction = exports.updateAccruedJESchedules = exports.updateJESchedules = exports.initialState = void 0;
8
8
  const toolkit_1 = require("@reduxjs/toolkit");
9
9
  const assignWith_1 = __importDefault(require("lodash/assignWith"));
10
10
  const jeSchedulesPayload_1 = require("./jeSchedulesPayload");
11
11
  exports.initialState = {
12
12
  schedulesByTransactionKey: {},
13
+ schedulesByAccruedJEScheduleKey: {},
13
14
  };
14
15
  const jeSchedules = (0, toolkit_1.createSlice)({
15
16
  name: 'jeSchedules',
@@ -27,11 +28,48 @@ const jeSchedules = (0, toolkit_1.createSlice)({
27
28
  // do nothing here
28
29
  },
29
30
  },
31
+ updateAccruedJESchedules: {
32
+ prepare(jeAccruedSchedulesTransactionsPayload) {
33
+ return {
34
+ payload: {
35
+ jeAccruedSchedulesTransactionsPayload,
36
+ },
37
+ };
38
+ },
39
+ reducer() {
40
+ // do nothing here
41
+ },
42
+ },
30
43
  updateJEScheduledTransaction: (draft, action) => {
31
44
  action.payload.jeSchedulesTransactionsPayload.forEach((schedule) => {
32
45
  doUpdateJEScheduledTransaction(draft.schedulesByTransactionKey, (0, jeSchedulesPayload_1.getTransactionDetailKeyPayload)(schedule.base_transaction), schedule, 'merge');
33
46
  });
34
47
  },
48
+ updateAccruedJEScheduledTransaction: (draft, action) => {
49
+ action.payload.jeAccruedSchedulesTransactionsPayload.forEach((schedule) => {
50
+ doUpdateJEAccruedScheduledTransaction(draft.schedulesByAccruedJEScheduleKey, (0, jeSchedulesPayload_1.getJEScheduleKey)(schedule), schedule, 'merge');
51
+ });
52
+ },
53
+ updateAccruedJESchedulesDetails: {
54
+ prepare(jeSchedulesPayload, scheduledJEntriesPayload, updateType = 'merge') {
55
+ return {
56
+ payload: {
57
+ jeSchedulesPayload,
58
+ scheduledJEntriesPayload,
59
+ updateType,
60
+ },
61
+ };
62
+ },
63
+ reducer(draft, action) {
64
+ const { jeSchedulesPayload, updateType } = action.payload;
65
+ if (jeSchedulesPayload.length > 0) {
66
+ jeSchedulesPayload.forEach((jeSchedulePayload) => {
67
+ var _a;
68
+ doUpdateAccruedScheduledDetailTransaction(draft.schedulesByAccruedJEScheduleKey, (0, jeSchedulesPayload_1.getJEScheduleKey)(jeSchedulePayload), jeSchedulePayload, (_a = action.payload.scheduledJEntriesPayload) !== null && _a !== void 0 ? _a : [], updateType);
69
+ });
70
+ }
71
+ },
72
+ },
35
73
  updateJESchedulesDetails: {
36
74
  prepare(jeSchedulesPayload, scheduledJEntriesPayload, updateType = 'merge') {
37
75
  return {
@@ -54,24 +92,40 @@ const jeSchedules = (0, toolkit_1.createSlice)({
54
92
  },
55
93
  },
56
94
  deleteJESchedulesDetails: {
57
- prepare(jeScheduleKey) {
95
+ prepare(jeScheduleTransactionKey) {
58
96
  return {
59
97
  payload: {
60
- jeScheduleKey,
98
+ jeScheduleTransactionKey,
61
99
  },
62
100
  };
63
101
  },
64
102
  reducer(draft, action) {
65
- const jeScheduleKey = action.payload.jeScheduleKey;
66
- doDeleteScheduledDetailTransaction(draft.schedulesByTransactionKey, jeScheduleKey);
103
+ const jeScheduleTransactionKey = action.payload.jeScheduleTransactionKey;
104
+ doDeleteScheduledDetailTransaction(draft.schedulesByTransactionKey, jeScheduleTransactionKey);
105
+ },
106
+ },
107
+ deleteAccruedJESchedulesDetails: {
108
+ prepare(JEScheduleKey) {
109
+ return {
110
+ payload: {
111
+ JEScheduleKey,
112
+ },
113
+ };
114
+ },
115
+ reducer(draft, action) {
116
+ const JEScheduleKey = action.payload.JEScheduleKey;
117
+ delete draft.schedulesByAccruedJEScheduleKey[JEScheduleKey];
67
118
  },
68
119
  },
69
120
  clearAllJEScheduleTransactions(draft) {
70
121
  draft.schedulesByTransactionKey = {};
71
122
  },
123
+ clearAllAccruedJESchedules(draft) {
124
+ draft.schedulesByAccruedJEScheduleKey = {};
125
+ },
72
126
  },
73
127
  });
74
- _a = jeSchedules.actions, exports.updateJESchedules = _a.updateJESchedules, exports.updateJEScheduledTransaction = _a.updateJEScheduledTransaction, exports.updateJESchedulesDetails = _a.updateJESchedulesDetails, exports.deleteJESchedulesDetails = _a.deleteJESchedulesDetails, exports.clearAllJEScheduleTransactions = _a.clearAllJEScheduleTransactions;
128
+ _a = jeSchedules.actions, exports.updateJESchedules = _a.updateJESchedules, exports.updateAccruedJESchedules = _a.updateAccruedJESchedules, exports.updateJEScheduledTransaction = _a.updateJEScheduledTransaction, exports.updateAccruedJEScheduledTransaction = _a.updateAccruedJEScheduledTransaction, exports.updateJESchedulesDetails = _a.updateJESchedulesDetails, exports.updateAccruedJESchedulesDetails = _a.updateAccruedJESchedulesDetails, exports.deleteJESchedulesDetails = _a.deleteJESchedulesDetails, exports.deleteAccruedJESchedulesDetails = _a.deleteAccruedJESchedulesDetails, exports.clearAllAccruedJESchedules = _a.clearAllAccruedJESchedules, exports.clearAllJEScheduleTransactions = _a.clearAllJEScheduleTransactions;
75
129
  exports.default = jeSchedules.reducer;
76
130
  /**
77
131
  * Helper functions
@@ -86,9 +140,35 @@ function doUpdateJEScheduledTransaction(draft, id, payload, updateType) {
86
140
  draft[id] = jeTransaction;
87
141
  }
88
142
  }
143
+ function doUpdateJEAccruedScheduledTransaction(draft, id, payload, updateType) {
144
+ const jeTransaction = (0, jeSchedulesPayload_1.toJEAccruedScheduledTransaction)(payload);
145
+ const existingTransaction = draft[id];
146
+ if (existingTransaction != null && updateType === 'merge') {
147
+ (0, assignWith_1.default)(draft[id], jeTransaction, (objValue, srcValue) => srcValue !== null && srcValue !== void 0 ? srcValue : objValue); // IMPORTANT: replace the value only when source has valid value. Otherwise keep the existing value!
148
+ }
149
+ else {
150
+ draft[id] = jeTransaction;
151
+ }
152
+ }
89
153
  /**
90
154
  * Helper functions
91
155
  */
156
+ function doUpdateAccruedScheduledDetailTransaction(draft, id, jeSchedulePayload, scheduleJournalEntries, updateType) {
157
+ const jeTransaction = (0, jeSchedulesPayload_1.toJEAccruedScheduledTransaction)(jeSchedulePayload);
158
+ const { currencyCode, currencySymbol } = jeTransaction;
159
+ const scheduledJournalEntriesPayload = scheduleJournalEntries.filter((journalEntries) => journalEntries.je_schedule_id === jeTransaction.jeScheduleId);
160
+ let scheduledJournalEntries = [];
161
+ if (scheduledJournalEntriesPayload.length > 0) {
162
+ scheduledJournalEntries = scheduledJournalEntriesPayload.map((scheduleJePayload) => (0, jeSchedulesPayload_1.toScheduledJournalEntryState)(scheduleJePayload, currencyCode, currencySymbol));
163
+ }
164
+ const existingTransaction = draft[id];
165
+ if (existingTransaction != null && updateType === 'merge') {
166
+ (0, assignWith_1.default)(draft[id], Object.assign(Object.assign({}, jeTransaction), { scheduledJournalEntry: scheduledJournalEntries }), (objValue, srcValue) => srcValue !== null && srcValue !== void 0 ? srcValue : objValue); // IMPORTANT: replace the value only when source has valid value. Otherwise keep the existing value!
167
+ }
168
+ else {
169
+ draft[id] = Object.assign(Object.assign({}, jeTransaction), { scheduledJournalEntry: scheduledJournalEntries });
170
+ }
171
+ }
92
172
  function doUpdateScheduledDetailTransaction(draft, id, jeSchedulePayload, scheduleJournalEntries, updateType) {
93
173
  const jeTransaction = (0, jeSchedulesPayload_1.toJEScheduledTransaction)(jeSchedulePayload);
94
174
  const { currencyCode, currencySymbol } = jeTransaction;
@@ -8,7 +8,7 @@ import { JEScheduleOtherAttributes, ScheduleJournalStatusCode, ScheduleStatus }
8
8
  import { ScheduleTransaction } from '../transaction/stateTypes/scheduleTransaction';
9
9
  import { User } from '../user/userState';
10
10
  import { RootState } from '../../reducer';
11
- import { JEScheduleKey } from './jeSchedulesTypes';
11
+ import { JEScheduleKey, JEScheduleTransactionKey } from './jeSchedulesTypes';
12
12
  import { TransactionID } from '../transaction/stateTypes/transaction';
13
13
  import { ScheduleDaysOfMonth } from '../../commonStateTypes/timePeriod';
14
14
  export interface ScheduledJournalEntry {
@@ -18,7 +18,10 @@ export interface ScheduledJournalEntry {
18
18
  expectedPostDate: ZeniDate;
19
19
  thirdPartyID?: ID;
20
20
  transactionID?: ID;
21
+ reversalThirdPartyID?: ID;
22
+ reversalTransactionID?: ID;
21
23
  recommendedTransactionID?: TransactionID;
24
+ reversalTransactionDetails?: TransactionID;
22
25
  actualPostDate?: ZeniDate;
23
26
  amount?: Amount;
24
27
  runningBalance?: Amount;
@@ -30,11 +33,19 @@ export interface ScheduledJournalEntry {
30
33
  currencyCode?: string;
31
34
  currencySymbol?: string;
32
35
  }
36
+ export interface JEAccruedSchedule extends Omit<JEScheduledTransaction, 'baseTransaction' | 'jeScheduleId' | 'jeScheduleTransactionKey'> {
37
+ jeAccruedScheduleKey: JEScheduleKey;
38
+ jeScheduleId: ID;
39
+ recurringAmount: Amount;
40
+ memo: string;
41
+ createTime: ZeniDate;
42
+ otherAttributes: JEScheduleOtherAttributes;
43
+ }
33
44
  export interface JEScheduledTransaction {
34
45
  status: ScheduleStatus;
35
46
  vendor: Vendor;
36
47
  baseTransaction: ScheduleTransaction;
37
- jeScheduleTransactionKey: JEScheduleKey;
48
+ jeScheduleTransactionKey: JEScheduleTransactionKey;
38
49
  currencyCode: string;
39
50
  currencySymbol: string;
40
51
  jeCredit: {
@@ -57,4 +68,5 @@ export interface JEScheduledTransaction {
57
68
  endDate?: ZeniDate;
58
69
  scheduledJournalEntry: ScheduledJournalEntry[];
59
70
  }
60
- export declare const getJEScheduledTransactionByJEScheduleKey: (jeScheduleKey: JEScheduleKey, state: RootState) => JEScheduledTransaction;
71
+ export declare const getJEAccruedScheduleByJEScheduleKey: (JEScheduleKey: `${string}_${string}`, state: RootState) => JEAccruedSchedule | undefined;
72
+ export declare const getJEScheduledTransactionByJEScheduleTransactionKey: (jeScheduleTransactionKey: JEScheduleTransactionKey, state: RootState) => JEScheduledTransaction;