@zeniai/client-epic-state 5.1.55 → 5.1.57-beta0GS

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 (40) hide show
  1. package/lib/entity/accountRecon/accountReconPayload.d.ts +1 -1
  2. package/lib/entity/accountRecon/accountReconReducer.js +15 -1
  3. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  4. package/lib/entity/tenant/clearAllEpic.js +2 -0
  5. package/lib/epic.d.ts +3 -1
  6. package/lib/epic.js +3 -1
  7. package/lib/esm/entity/accountRecon/accountReconReducer.js +15 -1
  8. package/lib/esm/entity/tenant/clearAllEpic.js +2 -0
  9. package/lib/esm/epic.js +3 -1
  10. package/lib/esm/index.js +5 -3
  11. package/lib/esm/reducer.js +3 -0
  12. package/lib/esm/view/expenseAutomationView/selectors/statementParseViewSelector.js +0 -224
  13. package/lib/esm/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +21 -0
  14. package/lib/esm/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.js +20 -0
  15. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.js +1 -0
  16. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.js +76 -0
  17. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.js +9 -0
  18. package/lib/esm/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.js +1 -0
  19. package/lib/esm/view/transactionDetail/transactionDetailLocalDataHelper.js +28 -0
  20. package/lib/index.d.ts +8 -4
  21. package/lib/index.js +46 -42
  22. package/lib/reducer.d.ts +3 -0
  23. package/lib/reducer.js +3 -0
  24. package/lib/view/expenseAutomationView/selectors/statementParseViewSelector.d.ts +1 -15
  25. package/lib/view/expenseAutomationView/selectors/statementParseViewSelector.js +1 -233
  26. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +7 -44
  27. package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.d.ts +7 -0
  28. package/lib/view/settings/jeScheduleApprovalRules/epic/fetchJEScheduleApprovalRulesEpic.js +25 -0
  29. package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.d.ts +6 -0
  30. package/lib/view/settings/jeScheduleApprovalRules/epic/saveJEScheduleApprovalRulesEpic.js +24 -0
  31. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.d.ts +29 -0
  32. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesPayload.js +2 -0
  33. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.d.ts +16 -0
  34. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesReducer.js +80 -0
  35. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.d.ts +12 -0
  36. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesSelector.js +12 -0
  37. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.d.ts +8 -0
  38. package/lib/view/settings/jeScheduleApprovalRules/jeScheduleApprovalRulesState.js +2 -0
  39. package/lib/view/transactionDetail/transactionDetailLocalDataHelper.js +28 -0
  40. package/package.json +1 -1
@@ -1,5 +1,4 @@
1
- import { AccountType } from '../../../entity/account/accountState';
2
- import { ApplyStatementParseFormChangeInput, ApplyStatementParseFormChangeResult, GetStatementParseFormViewInput, ParsedStatementData, StatementMeta, StatementParseFormView, StatementParseManualBalanceField, StatementTransaction, StatementUpdateLocalData, ToStatementUpdateLocalDataFromFormViewInput } from '../types/reconciliationViewState';
1
+ import { ParsedStatementData, StatementMeta, StatementTransaction, StatementUpdateLocalData } from '../types/reconciliationViewState';
3
2
  export interface StatementPeriod {
4
3
  statementEndDate: string;
5
4
  statementStartDate: string;
@@ -10,17 +9,4 @@ export declare const filterStatementTransactionsByPeriod: (transactions: Stateme
10
9
  export declare const getParsedStatementDataForView: (parsedStatementData: ParsedStatementData | undefined, statementUpdateLocalData: StatementUpdateLocalData | undefined) => ParsedStatementData | undefined;
11
10
  export declare const getStatementTransactionPeriodById: (allParsedTransactions: StatementTransaction[], parsedMeta: StatementMeta, localMeta: StatementMeta | undefined) => Record<string, boolean>;
12
11
  export declare const getDateFilteredDeletedTransactionIds: (allParsedTransactions: StatementTransaction[], statementPeriod: StatementPeriod) => string[];
13
- export declare const isStatementParseTransactionFieldChange: (changedField: string | undefined) => boolean;
14
- export declare const isStatementParseManualBalanceField: (field: string | undefined) => field is StatementParseManualBalanceField;
15
- export declare const shouldRecalculateStatementParseBalances: (changedField: string | undefined) => boolean;
16
- export declare const resolveStatementParseBalanceFields: (formView: StatementParseFormView, changedField: string | undefined, accountType?: AccountType) => {
17
- closingBalance: number;
18
- openingBalance: number;
19
- totalDeposits: number;
20
- totalPayments: number;
21
- };
22
- export declare const areStatementParseBalancesConsistent: (formView: StatementParseFormView, accountType?: AccountType) => boolean;
23
12
  export declare const mergeStatementParseDeletedTransactionIds: (originalTransactions: StatementTransaction[], statementPeriod: StatementPeriod, currentTransactionIds: Set<string>) => string[];
24
- export declare const getStatementParseFormView: ({ accountType, parsedStatementMeta, originalTransactions, statementUpdateLocalData, }: GetStatementParseFormViewInput) => StatementParseFormView;
25
- export declare const toStatementUpdateLocalDataFromFormView: ({ accountType, formView, parsedStatementMeta, originalTransactions, changedField, }: ToStatementUpdateLocalDataFromFormViewInput) => StatementUpdateLocalData;
26
- export declare const applyStatementParseFormChange: ({ accountType, formView, changedField, parsedStatementMeta, originalTransactions, }: ApplyStatementParseFormChangeInput) => ApplyStatementParseFormChangeResult;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyStatementParseFormChange = exports.toStatementUpdateLocalDataFromFormView = exports.getStatementParseFormView = exports.mergeStatementParseDeletedTransactionIds = exports.areStatementParseBalancesConsistent = exports.resolveStatementParseBalanceFields = exports.shouldRecalculateStatementParseBalances = exports.isStatementParseManualBalanceField = exports.isStatementParseTransactionFieldChange = exports.getDateFilteredDeletedTransactionIds = exports.getStatementTransactionPeriodById = exports.getParsedStatementDataForView = exports.filterStatementTransactionsByPeriod = exports.isStatementTransactionInPeriod = exports.getEffectiveStatementPeriod = void 0;
3
+ exports.mergeStatementParseDeletedTransactionIds = exports.getDateFilteredDeletedTransactionIds = exports.getStatementTransactionPeriodById = exports.getParsedStatementDataForView = exports.filterStatementTransactionsByPeriod = exports.isStatementTransactionInPeriod = exports.getEffectiveStatementPeriod = void 0;
4
4
  const zeniDayJS_1 = require("../../../zeniDayJS");
5
5
  const getEffectiveStatementPeriod = (parsedMeta, localMeta) => ({
6
6
  statementStartDate: localMeta?.statementStartDate != null && localMeta.statementStartDate !== ''
@@ -73,122 +73,6 @@ const getDateFilteredDeletedTransactionIds = (allParsedTransactions, statementPe
73
73
  .map((transaction) => transaction.statementTransactionId);
74
74
  };
75
75
  exports.getDateFilteredDeletedTransactionIds = getDateFilteredDeletedTransactionIds;
76
- const roundCurrency = (value) => Math.round(value * 100) / 100;
77
- const toApiDateString = (value) => {
78
- if (value == null || value === '') {
79
- return '';
80
- }
81
- return (0, zeniDayJS_1.date)(value).format('YYYY-MM-DD');
82
- };
83
- const computeStatementTransactionTotals = (transactions) => {
84
- const totalDeposits = roundCurrency(transactions
85
- .filter((txn) => txn.transactionDirection === 'credit')
86
- .reduce((sum, txn) => sum + Math.abs(txn.amount ?? 0), 0));
87
- const totalPayments = roundCurrency(transactions
88
- .filter((txn) => txn.transactionDirection === 'debit')
89
- .reduce((sum, txn) => sum + Math.abs(txn.amount ?? 0), 0));
90
- return { totalDeposits, totalPayments };
91
- };
92
- const computeStatementClosingBalance = (openingBalance, totalDeposits, totalPayments, accountType) => roundCurrency(accountType === 'credit_card'
93
- ? openingBalance + totalPayments - totalDeposits
94
- : openingBalance + totalDeposits - totalPayments);
95
- const filterFormTransactionsInPeriod = (transactions, statementStartDate, statementEndDate) => {
96
- if (statementStartDate === '' || statementEndDate === '') {
97
- return transactions;
98
- }
99
- const periodStart = (0, zeniDayJS_1.date)(statementStartDate).startOf('day');
100
- const periodEnd = (0, zeniDayJS_1.date)(statementEndDate).startOf('day');
101
- return transactions.filter((txn) => {
102
- if (txn.transactionDate === '') {
103
- return true;
104
- }
105
- const txnDate = (0, zeniDayJS_1.date)(txn.transactionDate).startOf('day');
106
- return (txnDate.isSameOrAfter(periodStart, 'day') &&
107
- txnDate.isSameOrBefore(periodEnd, 'day'));
108
- });
109
- };
110
- const isStatementParseTransactionFieldChange = (changedField) => changedField === 'transactions' ||
111
- changedField?.startsWith('transactions.') === true;
112
- exports.isStatementParseTransactionFieldChange = isStatementParseTransactionFieldChange;
113
- const isStatementParseBalanceAffectingTransactionFieldChange = (changedField) => {
114
- if (changedField === 'transactions') {
115
- return true;
116
- }
117
- if (changedField?.startsWith('transactions.') !== true) {
118
- return false;
119
- }
120
- return !changedField.endsWith('.transactionMemo');
121
- };
122
- const isStatementParseManualBalanceField = (field) => field === 'totalDeposits' ||
123
- field === 'totalPayments' ||
124
- field === 'closingBalance';
125
- exports.isStatementParseManualBalanceField = isStatementParseManualBalanceField;
126
- const shouldRecalculateStatementParseBalances = (changedField) => isStatementParseBalanceAffectingTransactionFieldChange(changedField) ||
127
- changedField === 'statementStartDate' ||
128
- changedField === 'statementEndDate';
129
- exports.shouldRecalculateStatementParseBalances = shouldRecalculateStatementParseBalances;
130
- const resolveStatementParseBalanceFields = (formView, changedField, accountType) => {
131
- const inPeriodTransactions = filterFormTransactionsInPeriod(formView.transactions, formView.statementStartDate, formView.statementEndDate);
132
- const { totalDeposits, totalPayments } = computeStatementTransactionTotals(inPeriodTransactions);
133
- if (!(0, exports.shouldRecalculateStatementParseBalances)(changedField)) {
134
- return {
135
- openingBalance: formView.openingBalance,
136
- closingBalance: formView.closingBalance,
137
- totalDeposits: formView.totalDeposits,
138
- totalPayments: formView.totalPayments,
139
- };
140
- }
141
- return {
142
- openingBalance: formView.openingBalance,
143
- totalDeposits,
144
- totalPayments,
145
- closingBalance: computeStatementClosingBalance(formView.openingBalance, totalDeposits, totalPayments, accountType),
146
- };
147
- };
148
- exports.resolveStatementParseBalanceFields = resolveStatementParseBalanceFields;
149
- const areStatementParseBalancesConsistent = (formView, accountType) => {
150
- // Validate the four balance fields against each other (what the user sees),
151
- // not against recomputed transaction totals. Manual deposits/payments edits
152
- // are allowed as long as closing matches the account-type formula.
153
- return (roundCurrency(formView.closingBalance) ===
154
- computeStatementClosingBalance(formView.openingBalance, formView.totalDeposits, formView.totalPayments, accountType));
155
- };
156
- exports.areStatementParseBalancesConsistent = areStatementParseBalancesConsistent;
157
- const mapParsedTransactionToFormRow = (transaction, index) => ({
158
- id: transaction.statementTransactionId || `parsed-${index}`,
159
- transactionDate: toApiDateString(transaction.transactionDate),
160
- transactionMemo: transaction.transactionMemo,
161
- amount: transaction.amount,
162
- transactionDirection: transaction.transactionDirection,
163
- statementTransactionId: transaction.statementTransactionId,
164
- });
165
- const mapLocalTransactionToFormRow = (transaction, id) => ({
166
- id,
167
- transactionDate: toApiDateString(transaction.transactionDate),
168
- transactionMemo: transaction.transactionMemo,
169
- amount: transaction.amount,
170
- transactionDirection: transaction.transactionDirection,
171
- statementTransactionId: transaction.statementTransactionId,
172
- });
173
- const buildStatementParseFormTransactions = (originalTransactions, localData) => {
174
- const deletedIdSet = new Set(localData.statementTransactions?.deletedIds ?? []);
175
- const updatedById = new Map((localData.statementTransactions?.updated ?? [])
176
- .filter((transaction) => transaction.statementTransactionId != null)
177
- .map((transaction) => [
178
- transaction.statementTransactionId,
179
- transaction,
180
- ]));
181
- const persistedTransactions = originalTransactions
182
- .filter((transaction) => !deletedIdSet.has(transaction.statementTransactionId))
183
- .map((transaction, index) => {
184
- const updated = updatedById.get(transaction.statementTransactionId);
185
- return updated != null
186
- ? mapLocalTransactionToFormRow(updated, transaction.statementTransactionId)
187
- : mapParsedTransactionToFormRow(transaction, index);
188
- });
189
- const addedTransactions = (localData.statementTransactions?.added ?? []).map((transaction, index) => mapLocalTransactionToFormRow(transaction, `added-${index}`));
190
- return [...persistedTransactions, ...addedTransactions];
191
- };
192
76
  const mergeStatementParseDeletedTransactionIds = (originalTransactions, statementPeriod, currentTransactionIds) => {
193
77
  const dateFilteredDeletedIds = (0, exports.getDateFilteredDeletedTransactionIds)(originalTransactions, statementPeriod);
194
78
  const dateFilteredDeletedIdSet = new Set(dateFilteredDeletedIds);
@@ -200,119 +84,3 @@ const mergeStatementParseDeletedTransactionIds = (originalTransactions, statemen
200
84
  return [...new Set([...userDeletedIds, ...dateFilteredDeletedIds])];
201
85
  };
202
86
  exports.mergeStatementParseDeletedTransactionIds = mergeStatementParseDeletedTransactionIds;
203
- const resolveStatementMetaDates = (parsedStatementMeta, localMeta) => ({
204
- statementStartDate: localMeta?.statementStartDate != null && localMeta.statementStartDate !== ''
205
- ? localMeta.statementStartDate
206
- : (parsedStatementMeta?.statementStartDate ?? ''),
207
- statementEndDate: localMeta?.statementEndDate != null && localMeta.statementEndDate !== ''
208
- ? localMeta.statementEndDate
209
- : (parsedStatementMeta?.statementEndDate ?? ''),
210
- });
211
- const getStatementParseFormView = ({ accountType, parsedStatementMeta, originalTransactions, statementUpdateLocalData, }) => {
212
- const transactions = statementUpdateLocalData != null
213
- ? buildStatementParseFormTransactions(originalTransactions, statementUpdateLocalData)
214
- : originalTransactions.map(mapParsedTransactionToFormRow);
215
- const localMeta = statementUpdateLocalData?.statementMeta;
216
- const { statementStartDate, statementEndDate } = resolveStatementMetaDates(parsedStatementMeta, localMeta);
217
- const { totalDeposits, totalPayments } = computeStatementTransactionTotals(filterFormTransactionsInPeriod(transactions, statementStartDate, statementEndDate));
218
- const openingBalance = localMeta?.openingBalance ?? parsedStatementMeta?.openingBalance ?? 0;
219
- const computedClosingBalance = computeStatementClosingBalance(openingBalance, totalDeposits, totalPayments, accountType);
220
- return {
221
- statementStartDate,
222
- statementEndDate,
223
- openingBalance,
224
- closingBalance: localMeta?.closingBalance ?? computedClosingBalance,
225
- totalDeposits: localMeta?.totalDeposits ?? totalDeposits,
226
- totalPayments: localMeta?.totalPayments ?? totalPayments,
227
- transactions: filterFormTransactionsInPeriod(transactions, statementStartDate, statementEndDate),
228
- };
229
- };
230
- exports.getStatementParseFormView = getStatementParseFormView;
231
- const toStatementUpdateLocalDataFromFormView = ({ accountType, formView, parsedStatementMeta, originalTransactions, changedField, }) => {
232
- const balanceFields = (0, exports.resolveStatementParseBalanceFields)(formView, changedField, accountType);
233
- const currentTransactionIds = new Set(formView.transactions
234
- .map((transaction) => transaction.statementTransactionId)
235
- .filter((id) => id != null && id !== ''));
236
- const added = [];
237
- const updated = [];
238
- formView.transactions.forEach((transaction) => {
239
- const transactionDate = toApiDateString(transaction.transactionDate);
240
- if (transaction.statementTransactionId == null) {
241
- if (transaction.transactionDirection != null) {
242
- added.push({
243
- amount: transaction.amount,
244
- transactionDate,
245
- transactionDirection: transaction.transactionDirection,
246
- transactionMemo: transaction.transactionMemo,
247
- });
248
- }
249
- return;
250
- }
251
- const original = originalTransactions.find((candidate) => candidate.statementTransactionId === transaction.statementTransactionId);
252
- if (original != null &&
253
- (original.amount !== transaction.amount ||
254
- toApiDateString(original.transactionDate) !== transactionDate ||
255
- original.transactionMemo !== transaction.transactionMemo)) {
256
- updated.push({
257
- amount: transaction.amount,
258
- transactionDate,
259
- transactionDirection: transaction.transactionDirection,
260
- transactionMemo: transaction.transactionMemo,
261
- statementTransactionId: transaction.statementTransactionId,
262
- });
263
- }
264
- });
265
- const statementPeriod = {
266
- statementStartDate: toApiDateString(formView.statementStartDate),
267
- statementEndDate: toApiDateString(formView.statementEndDate),
268
- };
269
- const deletedIds = (0, exports.mergeStatementParseDeletedTransactionIds)(originalTransactions, statementPeriod, currentTransactionIds);
270
- const deletedIdSet = new Set(deletedIds);
271
- const inPeriodAdded = filterFormTransactionsInPeriod(added, statementPeriod.statementStartDate, statementPeriod.statementEndDate);
272
- const inPeriodUpdated = updated.filter((transaction) => transaction.statementTransactionId != null &&
273
- !deletedIdSet.has(transaction.statementTransactionId));
274
- return {
275
- statementMeta: {
276
- closingBalance: balanceFields.closingBalance,
277
- openingBalance: balanceFields.openingBalance,
278
- statementDataStatus: parsedStatementMeta?.statementDataStatus ?? {
279
- code: '',
280
- label: '',
281
- },
282
- statementEndDate: statementPeriod.statementEndDate,
283
- statementStartDate: statementPeriod.statementStartDate,
284
- statementStatus: parsedStatementMeta?.statementStatus ?? {
285
- code: '',
286
- label: '',
287
- },
288
- statementUploadId: parsedStatementMeta?.statementUploadId ?? '',
289
- totalDeposits: balanceFields.totalDeposits,
290
- totalPayments: balanceFields.totalPayments,
291
- },
292
- statementTransactions: {
293
- added: inPeriodAdded,
294
- deletedIds,
295
- updated: inPeriodUpdated,
296
- },
297
- };
298
- };
299
- exports.toStatementUpdateLocalDataFromFormView = toStatementUpdateLocalDataFromFormView;
300
- const applyStatementParseFormChange = ({ accountType, formView, changedField, parsedStatementMeta, originalTransactions, }) => {
301
- const balanceFields = (0, exports.resolveStatementParseBalanceFields)(formView, changedField, accountType);
302
- const shouldRecalculate = (0, exports.shouldRecalculateStatementParseBalances)(changedField);
303
- const mergedFormView = shouldRecalculate
304
- ? { ...formView, ...balanceFields }
305
- : formView;
306
- return {
307
- didRecalculateBalances: shouldRecalculate,
308
- formView: mergedFormView,
309
- localData: (0, exports.toStatementUpdateLocalDataFromFormView)({
310
- accountType,
311
- formView: mergedFormView,
312
- parsedStatementMeta,
313
- originalTransactions,
314
- changedField,
315
- }),
316
- };
317
- };
318
- exports.applyStatementParseFormChange = applyStatementParseFormChange;
@@ -2,7 +2,7 @@ import { Amount } from '../../../commonStateTypes/amount';
2
2
  import { FetchStateAndError, ID } from '../../../commonStateTypes/common';
3
3
  import { SortOrder } from '../../../commonStateTypes/selectorTypes/sortOrderTypes';
4
4
  import { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
5
- import { AccountType, ReconciliationAccountSourceType } from '../../../entity/account/accountState';
5
+ import { ReconciliationAccountSourceType } from '../../../entity/account/accountState';
6
6
  import { BankStatusCodeType } from '../../../entity/accountRecon/accountReconState';
7
7
  import { CustomerBase } from '../../../entity/customer/customerState';
8
8
  import { VendorBase } from '../../../entity/vendor/vendorState';
@@ -251,6 +251,12 @@ export interface StatementTransactionForUpdate {
251
251
  transactionDate: string;
252
252
  transactionDirection: 'debit' | 'credit';
253
253
  transactionMemo: string;
254
+ /**
255
+ * Client-only stable id for unsaved added rows. Preserved across local-data
256
+ * rebuilds so form rows survive add/delete without index remapping. Not sent
257
+ * to the API.
258
+ */
259
+ id?: string;
254
260
  statementTransactionId?: string;
255
261
  }
256
262
  export interface StatementTransactionsUpdate {
@@ -258,49 +264,6 @@ export interface StatementTransactionsUpdate {
258
264
  deletedIds: string[];
259
265
  updated: StatementTransactionForUpdate[];
260
266
  }
261
- export type StatementParseManualBalanceField = 'totalDeposits' | 'totalPayments' | 'closingBalance';
262
- export interface StatementParseFormTransaction {
263
- amount: number;
264
- id: string;
265
- transactionDate: string;
266
- transactionDirection: 'debit' | 'credit';
267
- transactionMemo: string;
268
- statementTransactionId?: string;
269
- }
270
- export interface StatementParseFormView {
271
- closingBalance: number;
272
- openingBalance: number;
273
- statementEndDate: string;
274
- statementStartDate: string;
275
- totalDeposits: number;
276
- totalPayments: number;
277
- transactions: StatementParseFormTransaction[];
278
- }
279
- export interface GetStatementParseFormViewInput {
280
- originalTransactions: StatementTransaction[];
281
- parsedStatementMeta: StatementMeta | undefined;
282
- statementUpdateLocalData: StatementUpdateLocalData | undefined;
283
- accountType?: AccountType;
284
- }
285
- export interface ToStatementUpdateLocalDataFromFormViewInput {
286
- formView: StatementParseFormView;
287
- originalTransactions: StatementTransaction[];
288
- parsedStatementMeta: StatementMeta | undefined;
289
- accountType?: AccountType;
290
- changedField?: string;
291
- }
292
- export interface ApplyStatementParseFormChangeInput {
293
- formView: StatementParseFormView;
294
- originalTransactions: StatementTransaction[];
295
- parsedStatementMeta: StatementMeta | undefined;
296
- accountType?: AccountType;
297
- changedField?: string;
298
- }
299
- export interface ApplyStatementParseFormChangeResult {
300
- didRecalculateBalances: boolean;
301
- formView: StatementParseFormView;
302
- localData: StatementUpdateLocalData;
303
- }
304
267
  export interface StatementUpdateLocalData {
305
268
  statementMeta: StatementMeta;
306
269
  statementTransactions: StatementTransactionsUpdate;
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../reducer';
4
+ import { ZeniAPI } from '../../../../zeniAPI';
5
+ import { fetchJEScheduleApprovalRules, fetchJEScheduleApprovalRulesFailure, fetchJEScheduleApprovalRulesSuccess } from '../jeScheduleApprovalRulesReducer';
6
+ export type ActionType = ReturnType<typeof fetchJEScheduleApprovalRules> | ReturnType<typeof fetchJEScheduleApprovalRulesSuccess> | ReturnType<typeof fetchJEScheduleApprovalRulesFailure>;
7
+ export declare const fetchJEScheduleApprovalRulesEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchJEScheduleApprovalRulesEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../../responsePayload");
7
+ const jeScheduleApprovalRulesReducer_1 = require("../jeScheduleApprovalRulesReducer");
8
+ const fetchJEScheduleApprovalRulesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRules.match), (0, operators_1.switchMap)((action) => {
9
+ const { cacheOverride } = action.payload;
10
+ const { jeScheduleApprovalRulesState } = state$.value;
11
+ const cachedSettings = jeScheduleApprovalRulesState.settings;
12
+ if (cacheOverride !== true &&
13
+ jeScheduleApprovalRulesState.hasValidState() === true &&
14
+ cachedSettings != null) {
15
+ return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesSuccess)(cachedSettings));
16
+ }
17
+ const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/je-schedules/approval-rules`;
18
+ return zeniAPI.getJSON(endpoint).pipe((0, operators_1.mergeMap)((response) => {
19
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
20
+ return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesSuccess)(response.data.settings));
21
+ }
22
+ return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesFailure)(response.status));
23
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.fetchJEScheduleApprovalRulesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch JE approval rules errored out' + JSON.stringify(error))))));
24
+ }));
25
+ exports.fetchJEScheduleApprovalRulesEpic = fetchJEScheduleApprovalRulesEpic;
@@ -0,0 +1,6 @@
1
+ import { ActionsObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { ZeniAPI } from '../../../../zeniAPI';
4
+ import { saveJEScheduleApprovalRules, saveJEScheduleApprovalRulesConflict, saveJEScheduleApprovalRulesFailure, saveJEScheduleApprovalRulesSuccess } from '../jeScheduleApprovalRulesReducer';
5
+ export type ActionType = ReturnType<typeof saveJEScheduleApprovalRules> | ReturnType<typeof saveJEScheduleApprovalRulesSuccess> | ReturnType<typeof saveJEScheduleApprovalRulesConflict> | ReturnType<typeof saveJEScheduleApprovalRulesFailure>;
6
+ export declare const saveJEScheduleApprovalRulesEpic: (actions$: ActionsObservable<ActionType>, _state$: unknown, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveJEScheduleApprovalRulesEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../../../responsePayload");
7
+ const jeScheduleApprovalRulesReducer_1 = require("../jeScheduleApprovalRulesReducer");
8
+ const HTTP_CONFLICT = 409;
9
+ const saveJEScheduleApprovalRulesEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRules.match), (0, operators_1.mergeMap)((action) => {
10
+ const { body } = action.payload;
11
+ const endpoint = `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/je-schedules/approval-rules`;
12
+ return zeniAPI
13
+ .postAndGetJSON(endpoint, body)
14
+ .pipe((0, operators_1.mergeMap)((response) => {
15
+ if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
16
+ return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesSuccess)(response.data.settings, response.data.reevaluation_triggered));
17
+ }
18
+ if (response.status.code === HTTP_CONFLICT) {
19
+ return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesConflict)(response.status));
20
+ }
21
+ return (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesFailure)(response.status));
22
+ }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, jeScheduleApprovalRulesReducer_1.saveJEScheduleApprovalRulesFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save JE approval rules errored out' + JSON.stringify(error))))));
23
+ }));
24
+ exports.saveJEScheduleApprovalRulesEpic = saveJEScheduleApprovalRulesEpic;
@@ -0,0 +1,29 @@
1
+ import { ZeniAPIResponse } from '../../../responsePayload';
2
+ export type JEScheduleType = 'prepaid_expenses' | 'fixed_assets' | 'accrued_expenses';
3
+ export interface JEApprovalThresholdRow {
4
+ account_id: string;
5
+ account_name: string;
6
+ max_auto_post_amount: number | null;
7
+ schedule_type: JEScheduleType;
8
+ }
9
+ export interface JEApprovalSettings {
10
+ approver_roles: string[];
11
+ reevaluate_ongoing_on_threshold_change: boolean;
12
+ thresholds: JEApprovalThresholdRow[];
13
+ version: number;
14
+ }
15
+ export interface JEScheduleApprovalRulesResponseData {
16
+ exists: boolean;
17
+ settings: JEApprovalSettings;
18
+ }
19
+ export type JEScheduleApprovalRulesResponse = ZeniAPIResponse<JEScheduleApprovalRulesResponseData>;
20
+ export interface SaveJEScheduleApprovalRulesResponseData extends JEScheduleApprovalRulesResponseData {
21
+ reevaluation_triggered: boolean;
22
+ }
23
+ export type SaveJEScheduleApprovalRulesResponse = ZeniAPIResponse<SaveJEScheduleApprovalRulesResponseData>;
24
+ export interface SaveJEScheduleApprovalRulesRequestBody extends Record<string, unknown> {
25
+ approver_roles: string[];
26
+ reevaluate_ongoing_on_threshold_change: boolean;
27
+ thresholds: JEApprovalThresholdRow[];
28
+ expected_version?: number;
29
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import { ZeniAPIStatus } from '../../../responsePayload';
2
+ import { JEApprovalSettings, SaveJEScheduleApprovalRulesRequestBody } from './jeScheduleApprovalRulesPayload';
3
+ import { JEScheduleApprovalRulesState } from './jeScheduleApprovalRulesState';
4
+ export declare const initialState: JEScheduleApprovalRulesState;
5
+ export declare const fetchJEScheduleApprovalRules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any], {
6
+ cacheOverride: any;
7
+ }, "jeScheduleApprovalRules/fetchJEScheduleApprovalRules", never, never>, fetchJEScheduleApprovalRulesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[settings: JEApprovalSettings], {
8
+ settings: JEApprovalSettings;
9
+ }, "jeScheduleApprovalRules/fetchJEScheduleApprovalRulesSuccess", never, never>, fetchJEScheduleApprovalRulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "jeScheduleApprovalRules/fetchJEScheduleApprovalRulesFailure">, saveJEScheduleApprovalRules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[body: SaveJEScheduleApprovalRulesRequestBody], {
10
+ body: SaveJEScheduleApprovalRulesRequestBody;
11
+ }, "jeScheduleApprovalRules/saveJEScheduleApprovalRules", never, never>, saveJEScheduleApprovalRulesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[settings: JEApprovalSettings, reevaluationTriggered: boolean], {
12
+ settings: JEApprovalSettings;
13
+ reevaluationTriggered: boolean;
14
+ }, "jeScheduleApprovalRules/saveJEScheduleApprovalRulesSuccess", never, never>, saveJEScheduleApprovalRulesConflict: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "jeScheduleApprovalRules/saveJEScheduleApprovalRulesConflict">, saveJEScheduleApprovalRulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "jeScheduleApprovalRules/saveJEScheduleApprovalRulesFailure">, clearJEScheduleApprovalRules: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"jeScheduleApprovalRules/clearJEScheduleApprovalRules">;
15
+ declare const _default: import("redux").Reducer<JEScheduleApprovalRulesState>;
16
+ export default _default;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.clearJEScheduleApprovalRules = exports.saveJEScheduleApprovalRulesFailure = exports.saveJEScheduleApprovalRulesConflict = exports.saveJEScheduleApprovalRulesSuccess = exports.saveJEScheduleApprovalRules = exports.fetchJEScheduleApprovalRulesFailure = exports.fetchJEScheduleApprovalRulesSuccess = exports.fetchJEScheduleApprovalRules = exports.initialState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ exports.initialState = {
7
+ fetchState: 'Not-Started',
8
+ error: undefined,
9
+ saveStatus: { fetchState: 'Not-Started', error: undefined },
10
+ settings: undefined,
11
+ hadVersionConflict: false,
12
+ reevaluationTriggered: false,
13
+ hasValidState() {
14
+ return this.fetchState === 'Completed';
15
+ },
16
+ };
17
+ const jeScheduleApprovalRules = (0, toolkit_1.createSlice)({
18
+ name: 'jeScheduleApprovalRules',
19
+ initialState: exports.initialState,
20
+ reducers: {
21
+ fetchJEScheduleApprovalRules: {
22
+ reducer(draft) {
23
+ draft.fetchState = 'In-Progress';
24
+ draft.error = undefined;
25
+ },
26
+ prepare(cacheOverride = false) {
27
+ return { payload: { cacheOverride } };
28
+ },
29
+ },
30
+ fetchJEScheduleApprovalRulesSuccess: {
31
+ reducer(draft, action) {
32
+ draft.fetchState = 'Completed';
33
+ draft.error = undefined;
34
+ draft.settings = action.payload.settings;
35
+ },
36
+ prepare(settings) {
37
+ return { payload: { settings } };
38
+ },
39
+ },
40
+ fetchJEScheduleApprovalRulesFailure(draft, action) {
41
+ draft.fetchState = 'Error';
42
+ draft.error = action.payload;
43
+ },
44
+ saveJEScheduleApprovalRules: {
45
+ reducer(draft) {
46
+ draft.saveStatus = { fetchState: 'In-Progress', error: undefined };
47
+ draft.hadVersionConflict = false;
48
+ draft.reevaluationTriggered = false;
49
+ },
50
+ prepare(body) {
51
+ return { payload: { body } };
52
+ },
53
+ },
54
+ saveJEScheduleApprovalRulesSuccess: {
55
+ reducer(draft, action) {
56
+ draft.saveStatus = { fetchState: 'Completed', error: undefined };
57
+ draft.settings = action.payload.settings;
58
+ draft.reevaluationTriggered = action.payload.reevaluationTriggered;
59
+ draft.hadVersionConflict = false;
60
+ },
61
+ prepare(settings, reevaluationTriggered) {
62
+ return { payload: { settings, reevaluationTriggered } };
63
+ },
64
+ },
65
+ // 409 — the stored version moved under us. The screen should re-fetch and
66
+ // ask the user to re-apply. Kept distinct from a generic save failure.
67
+ saveJEScheduleApprovalRulesConflict(draft, action) {
68
+ draft.saveStatus = { fetchState: 'Error', error: action.payload };
69
+ draft.hadVersionConflict = true;
70
+ },
71
+ saveJEScheduleApprovalRulesFailure(draft, action) {
72
+ draft.saveStatus = { fetchState: 'Error', error: action.payload };
73
+ },
74
+ clearJEScheduleApprovalRules() {
75
+ return exports.initialState;
76
+ },
77
+ },
78
+ });
79
+ _a = jeScheduleApprovalRules.actions, exports.fetchJEScheduleApprovalRules = _a.fetchJEScheduleApprovalRules, exports.fetchJEScheduleApprovalRulesSuccess = _a.fetchJEScheduleApprovalRulesSuccess, exports.fetchJEScheduleApprovalRulesFailure = _a.fetchJEScheduleApprovalRulesFailure, exports.saveJEScheduleApprovalRules = _a.saveJEScheduleApprovalRules, exports.saveJEScheduleApprovalRulesSuccess = _a.saveJEScheduleApprovalRulesSuccess, exports.saveJEScheduleApprovalRulesConflict = _a.saveJEScheduleApprovalRulesConflict, exports.saveJEScheduleApprovalRulesFailure = _a.saveJEScheduleApprovalRulesFailure, exports.clearJEScheduleApprovalRules = _a.clearJEScheduleApprovalRules;
80
+ exports.default = jeScheduleApprovalRules.reducer;
@@ -0,0 +1,12 @@
1
+ import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common';
2
+ import { RootState } from '../../../reducer';
3
+ import { JEApprovalSettings } from './jeScheduleApprovalRulesPayload';
4
+ export interface JEScheduleApprovalRulesView {
5
+ error: FetchStateAndError['error'];
6
+ fetchState: FetchState;
7
+ hadVersionConflict: boolean;
8
+ reevaluationTriggered: boolean;
9
+ saveStatus: FetchStateAndError;
10
+ settings?: JEApprovalSettings;
11
+ }
12
+ export declare const getJEScheduleApprovalRulesView: (state: RootState) => JEScheduleApprovalRulesView;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getJEScheduleApprovalRulesView = void 0;
4
+ const toolkit_1 = require("@reduxjs/toolkit");
5
+ exports.getJEScheduleApprovalRulesView = (0, toolkit_1.createSelector)((state) => state.jeScheduleApprovalRulesState, (jeScheduleApprovalRulesState) => ({
6
+ fetchState: jeScheduleApprovalRulesState.fetchState,
7
+ error: jeScheduleApprovalRulesState.error,
8
+ saveStatus: jeScheduleApprovalRulesState.saveStatus,
9
+ settings: jeScheduleApprovalRulesState.settings,
10
+ hadVersionConflict: jeScheduleApprovalRulesState.hadVersionConflict ?? false,
11
+ reevaluationTriggered: jeScheduleApprovalRulesState.reevaluationTriggered ?? false,
12
+ }));
@@ -0,0 +1,8 @@
1
+ import { FetchStateAndError, FetchedState } from '../../../commonStateTypes/common';
2
+ import { JEApprovalSettings } from './jeScheduleApprovalRulesPayload';
3
+ export interface JEScheduleApprovalRulesState extends FetchedState {
4
+ saveStatus: FetchStateAndError;
5
+ hadVersionConflict?: boolean;
6
+ reevaluationTriggered?: boolean;
7
+ settings?: JEApprovalSettings;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });