@zeniai/client-epic-state 5.0.90-betaAR4 → 5.0.90-betaAR6
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.
- package/lib/entity/approvalRule/approvalRulePayload.d.ts +5 -34
- package/lib/entity/approvalRule/approvalRulePayload.js +10 -145
- package/lib/entity/approvalRule/approvalRuleSelector.d.ts +1 -25
- package/lib/entity/approvalRule/approvalRuleSelector.js +0 -40
- package/lib/entity/approvalRule/approvalRuleState.d.ts +7 -59
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -2
- package/lib/epic.d.ts +1 -3
- package/lib/epic.js +1 -3
- package/lib/esm/entity/approvalRule/approvalRulePayload.js +10 -145
- package/lib/esm/entity/approvalRule/approvalRuleSelector.js +0 -35
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -2
- package/lib/esm/epic.js +1 -3
- package/lib/esm/index.js +5 -7
- package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +163 -66
- package/lib/esm/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +0 -14
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +12 -102
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +7 -11
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +4 -13
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +16 -120
- package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +7 -11
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +4 -13
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +11 -76
- package/lib/index.d.ts +6 -8
- package/lib/index.js +16 -27
- package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
- package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/transactionFilterHelpers.js +163 -66
- package/lib/view/people/peopleTypes.d.ts +1 -1
- package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.d.ts +0 -7
- package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +0 -14
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +3 -14
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +13 -103
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewState.d.ts +0 -16
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +2 -10
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +4 -8
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +6 -10
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -12
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +1 -59
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +17 -122
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +5 -31
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +1 -8
- package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +4 -60
- package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +2 -10
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +2 -8
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +6 -10
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +3 -12
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +3 -14
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +12 -77
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewState.d.ts +0 -12
- package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
- package/lib/view/transactionDetail/journalEntryLinesViewModel.d.ts +1 -1
- package/package.json +1 -1
- package/lib/entity/approvalRule/approvalRuleConflict.d.ts +0 -56
- package/lib/entity/approvalRule/approvalRuleConflict.js +0 -77
- package/lib/esm/entity/approvalRule/approvalRuleConflict.js +0 -74
- package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -54
- package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -49
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.d.ts +0 -23
- package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/reorderBillPayApprovalRulesEpic.js +0 -58
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.d.ts +0 -14
- package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/reorderRemiApprovalRulesEpic.js +0 -53
|
@@ -7,19 +7,6 @@
|
|
|
7
7
|
* being implicitly coerced to falsy.
|
|
8
8
|
*/
|
|
9
9
|
const isNonEmptyString = (s) => s != null && s !== '';
|
|
10
|
-
/**
|
|
11
|
-
* First line item in UI order. `lineItemById` is a Record whose iteration
|
|
12
|
-
* order is not guaranteed to match what the user sees; `sortedLineItems`
|
|
13
|
-
* is the canonical ordering used by the categorization list/detail views.
|
|
14
|
-
*/
|
|
15
|
-
const getFirstLineItemFromReviewLocalData = (localData) => {
|
|
16
|
-
const { sortedLineItems, lineItemById } = localData;
|
|
17
|
-
if (sortedLineItems.length > 0) {
|
|
18
|
-
return lineItemById[sortedLineItems[0]];
|
|
19
|
-
}
|
|
20
|
-
const lineItems = Object.values(lineItemById);
|
|
21
|
-
return lineItems.length > 0 ? lineItems[0] : undefined;
|
|
22
|
-
};
|
|
23
10
|
export const TRANSACTION_FILTER_CATEGORIES = [
|
|
24
11
|
{ value: 'payment_account_name', type: 'dropdown' },
|
|
25
12
|
{ value: 'payment_account_type', type: 'dropdown' },
|
|
@@ -93,15 +80,141 @@ const getLineAmountsForTransaction = (transaction) => {
|
|
|
93
80
|
* instead).
|
|
94
81
|
*/
|
|
95
82
|
const isFiniteNumber = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
83
|
+
/**
|
|
84
|
+
* Per-line category (account) identifiers for a transaction. Source
|
|
85
|
+
* precedence mirrors `getLineAmountsForTransaction`:
|
|
86
|
+
*
|
|
87
|
+
* 1. `transactionLocalData.transactionReviewLocalData.lineItemById` —
|
|
88
|
+
* every locally-edited line item participates (not just the first
|
|
89
|
+
* sorted one, the way the old single-scalar `category` resolver did).
|
|
90
|
+
* 2. `transaction.transaction.lines` with the same type narrowing the
|
|
91
|
+
* old code used: only the three line types that carry an `account`
|
|
92
|
+
* (`transaction_with_account_and_class_line`,
|
|
93
|
+
* `transaction_with_product_or_service_line`,
|
|
94
|
+
* `journal_entry_transaction_line`) contribute. Payment-only / tax /
|
|
95
|
+
* discount lines are skipped rather than coerced to a sentinel.
|
|
96
|
+
*
|
|
97
|
+
* Each contributing line resolves to a single identifier via the same
|
|
98
|
+
* `accountId → qboId → accountName` fallback the old code used. Lines
|
|
99
|
+
* whose account is absent or blank everywhere drop out so the empty-array
|
|
100
|
+
* case bubbles up to `transactionMatchesCategory`'s absent-value contract
|
|
101
|
+
* (only `not_equal` matches a fully-missing identifier, every other
|
|
102
|
+
* operator excludes the row).
|
|
103
|
+
*/
|
|
104
|
+
const getLineCategoryIdentifiersForTransaction = (transaction) => {
|
|
105
|
+
const localData = transaction?.transactionLocalData?.transactionReviewLocalData;
|
|
106
|
+
if (localData?.lineItemById != null) {
|
|
107
|
+
const lineItems = Object.values(localData.lineItemById);
|
|
108
|
+
if (lineItems.length > 0) {
|
|
109
|
+
return lineItems
|
|
110
|
+
.map((lineItem) => resolveAccountIdentifier(lineItem?.account))
|
|
111
|
+
.filter(isNonEmptyString);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (transaction?.transaction?.lines != null &&
|
|
115
|
+
transaction.transaction.lines.length > 0) {
|
|
116
|
+
return transaction.transaction.lines
|
|
117
|
+
.map((line) => {
|
|
118
|
+
if (!isAccountAndClassLine(line)) {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
return resolveAccountIdentifier(line.account);
|
|
122
|
+
})
|
|
123
|
+
.filter(isNonEmptyString);
|
|
124
|
+
}
|
|
125
|
+
return [];
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Per-line class identifiers for a transaction. Same shape and precedence
|
|
129
|
+
* as `getLineCategoryIdentifiersForTransaction` but reads the `class`
|
|
130
|
+
* field on each line and uses the `classId → qboId → className` fallback.
|
|
131
|
+
*/
|
|
132
|
+
const getLineClassIdentifiersForTransaction = (transaction) => {
|
|
133
|
+
const localData = transaction?.transactionLocalData?.transactionReviewLocalData;
|
|
134
|
+
if (localData?.lineItemById != null) {
|
|
135
|
+
const lineItems = Object.values(localData.lineItemById);
|
|
136
|
+
if (lineItems.length > 0) {
|
|
137
|
+
return lineItems
|
|
138
|
+
.map((lineItem) => resolveClassIdentifier(lineItem?.class))
|
|
139
|
+
.filter(isNonEmptyString);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (transaction?.transaction?.lines != null &&
|
|
143
|
+
transaction.transaction.lines.length > 0) {
|
|
144
|
+
return transaction.transaction.lines
|
|
145
|
+
.map((line) => {
|
|
146
|
+
if (!isAccountAndClassLine(line)) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
return resolveClassIdentifier(line.class);
|
|
150
|
+
})
|
|
151
|
+
.filter(isNonEmptyString);
|
|
152
|
+
}
|
|
153
|
+
return [];
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Type-narrowing guard for the three persisted line shapes that carry an
|
|
157
|
+
* `account` + `class`. Kept as a single helper so the type list stays in
|
|
158
|
+
* one place if a new categorizable line variant is added.
|
|
159
|
+
*
|
|
160
|
+
* Typed against the union element produced by indexing `lines[number]` on
|
|
161
|
+
* the broader transaction type — the parameter is permitted to be
|
|
162
|
+
* `undefined` so callers can pass a possibly-sparse `lines` element
|
|
163
|
+
* without an extra null check.
|
|
164
|
+
*/
|
|
165
|
+
const isAccountAndClassLine = (line) => line?.type === 'transaction_with_account_and_class_line' ||
|
|
166
|
+
line?.type === 'transaction_with_product_or_service_line' ||
|
|
167
|
+
line?.type === 'journal_entry_transaction_line';
|
|
168
|
+
/**
|
|
169
|
+
* Resolve an `account` substructure to the comparable identifier the
|
|
170
|
+
* filter values are keyed by — same precedence the old single-scalar
|
|
171
|
+
* resolver used. `isNonEmptyString` rather than `??` so an empty-string
|
|
172
|
+
* placeholder doesn't shadow a meaningful later candidate.
|
|
173
|
+
*/
|
|
174
|
+
const resolveAccountIdentifier = (account) => {
|
|
175
|
+
if (account == null) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
if (isNonEmptyString(account.accountId)) {
|
|
179
|
+
return account.accountId;
|
|
180
|
+
}
|
|
181
|
+
if (isNonEmptyString(account.qboId)) {
|
|
182
|
+
return account.qboId;
|
|
183
|
+
}
|
|
184
|
+
if (isNonEmptyString(account.accountName)) {
|
|
185
|
+
return account.accountName;
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Mirror of `resolveAccountIdentifier` for the `class` substructure.
|
|
191
|
+
*/
|
|
192
|
+
const resolveClassIdentifier = (classData) => {
|
|
193
|
+
if (classData == null) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
if (isNonEmptyString(classData.classId)) {
|
|
197
|
+
return classData.classId;
|
|
198
|
+
}
|
|
199
|
+
if (isNonEmptyString(classData.qboId)) {
|
|
200
|
+
return classData.qboId;
|
|
201
|
+
}
|
|
202
|
+
if (isNonEmptyString(classData.className)) {
|
|
203
|
+
return classData.className;
|
|
204
|
+
}
|
|
205
|
+
return undefined;
|
|
206
|
+
};
|
|
96
207
|
/**
|
|
97
208
|
* Resolve the comparable value for a transaction against a given filter field.
|
|
98
209
|
* Returns undefined when the transaction doesn't carry the field — callers
|
|
99
210
|
* decide whether absence counts as a match (for 'not_equal' it does).
|
|
100
211
|
*
|
|
101
|
-
* NOTE: the `'amount'`
|
|
102
|
-
* per-line
|
|
103
|
-
* `
|
|
104
|
-
*
|
|
212
|
+
* NOTE: the `'amount'`, `'category'`, and `'class'` fields are NOT handled
|
|
213
|
+
* here. All three use per-line matching via the corresponding
|
|
214
|
+
* `getLine*ForTransaction` helper and an early-return in
|
|
215
|
+
* `transactionMatchesCategory` — they would otherwise need to return a
|
|
216
|
+
* non-scalar value that doesn't fit this helper's contract. Cases are
|
|
217
|
+
* preserved so the switch stays exhaustive over `TransactionFilterCategoryField`.
|
|
105
218
|
*/
|
|
106
219
|
const getCategoryValueForTransaction = (key, transaction) => {
|
|
107
220
|
switch (key) {
|
|
@@ -139,58 +252,13 @@ const getCategoryValueForTransaction = (key, transaction) => {
|
|
|
139
252
|
return transaction.transaction.paymentType;
|
|
140
253
|
}
|
|
141
254
|
case 'category': {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const firstLineItem = getFirstLineItemFromReviewLocalData(localDataForCategory);
|
|
145
|
-
const accountId = firstLineItem?.account?.accountId;
|
|
146
|
-
if (isNonEmptyString(accountId)) {
|
|
147
|
-
return accountId;
|
|
148
|
-
}
|
|
149
|
-
const qboId = firstLineItem?.account?.qboId;
|
|
150
|
-
if (isNonEmptyString(qboId)) {
|
|
151
|
-
return qboId;
|
|
152
|
-
}
|
|
153
|
-
const accountName = firstLineItem?.account?.accountName;
|
|
154
|
-
if (isNonEmptyString(accountName)) {
|
|
155
|
-
return accountName;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
const firstLineForCategory = transaction.transaction.lines?.[0];
|
|
159
|
-
if (firstLineForCategory?.type ===
|
|
160
|
-
'transaction_with_account_and_class_line' ||
|
|
161
|
-
firstLineForCategory?.type ===
|
|
162
|
-
'transaction_with_product_or_service_line' ||
|
|
163
|
-
firstLineForCategory?.type === 'journal_entry_transaction_line') {
|
|
164
|
-
const account = firstLineForCategory.account;
|
|
165
|
-
return account?.accountId ?? account?.qboId ?? account?.accountName;
|
|
166
|
-
}
|
|
255
|
+
// Handled per-line in `transactionMatchesCategory` — see
|
|
256
|
+
// `getLineCategoryIdentifiersForTransaction`.
|
|
167
257
|
return undefined;
|
|
168
258
|
}
|
|
169
259
|
case 'class': {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const firstLineItemForClass = getFirstLineItemFromReviewLocalData(localDataForClass);
|
|
173
|
-
const classId = firstLineItemForClass?.class?.classId;
|
|
174
|
-
if (isNonEmptyString(classId)) {
|
|
175
|
-
return classId;
|
|
176
|
-
}
|
|
177
|
-
const qboId = firstLineItemForClass?.class?.qboId;
|
|
178
|
-
if (isNonEmptyString(qboId)) {
|
|
179
|
-
return qboId;
|
|
180
|
-
}
|
|
181
|
-
const className = firstLineItemForClass?.class?.className;
|
|
182
|
-
if (isNonEmptyString(className)) {
|
|
183
|
-
return className;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
const firstLineForClass = transaction.transaction.lines?.[0];
|
|
187
|
-
if (firstLineForClass?.type === 'transaction_with_account_and_class_line' ||
|
|
188
|
-
firstLineForClass?.type ===
|
|
189
|
-
'transaction_with_product_or_service_line' ||
|
|
190
|
-
firstLineForClass?.type === 'journal_entry_transaction_line') {
|
|
191
|
-
const classData = firstLineForClass.class;
|
|
192
|
-
return classData?.classId ?? classData?.qboId ?? classData?.className;
|
|
193
|
-
}
|
|
260
|
+
// Handled per-line in `transactionMatchesCategory` — see
|
|
261
|
+
// `getLineClassIdentifiersForTransaction`.
|
|
194
262
|
return undefined;
|
|
195
263
|
}
|
|
196
264
|
default:
|
|
@@ -246,6 +314,35 @@ const matchAmount = (amount, category) => {
|
|
|
246
314
|
return op === 'not_equal' ? !matched : matched;
|
|
247
315
|
};
|
|
248
316
|
const transactionMatchesCategory = (transaction, category) => {
|
|
317
|
+
if (category.field === 'category' || category.field === 'class') {
|
|
318
|
+
// Per-line matching for category / class — mirrors the amount
|
|
319
|
+
// pattern below. A multi-line transaction surfaces when ANY of its
|
|
320
|
+
// lines has the selected account / class, instead of the old
|
|
321
|
+
// first-line-only behavior (which silently excluded transactions
|
|
322
|
+
// whose first sorted line wasn't categorized as the filter target,
|
|
323
|
+
// even if later lines were). The full row, with non-matching lines
|
|
324
|
+
// included, renders downstream. The matcher only decides row
|
|
325
|
+
// inclusion; it does NOT filter which lines are rendered inside the
|
|
326
|
+
// row.
|
|
327
|
+
//
|
|
328
|
+
// `not_equal` reads as "at least one line is NOT one of the filter
|
|
329
|
+
// values" — same `.some()` interpretation we adopted for amount.
|
|
330
|
+
// A row with lines [Software, Travel] matches `category != Software`
|
|
331
|
+
// (the Travel line satisfies the negation); a row with lines
|
|
332
|
+
// [Software, Software] does not (no line satisfies).
|
|
333
|
+
const lineIdentifiers = category.field === 'category'
|
|
334
|
+
? getLineCategoryIdentifiersForTransaction(transaction)
|
|
335
|
+
: getLineClassIdentifiersForTransaction(transaction);
|
|
336
|
+
if (lineIdentifiers.length === 0) {
|
|
337
|
+
// Absent-value contract — same as amount's empty-array branch.
|
|
338
|
+
return category.matchingOperator === 'not_equal';
|
|
339
|
+
}
|
|
340
|
+
const filterValuesAsStrings = new Set(category.values.map((v) => v.toString()));
|
|
341
|
+
return lineIdentifiers.some((id) => {
|
|
342
|
+
const inList = filterValuesAsStrings.has(id);
|
|
343
|
+
return category.matchingOperator === 'not_equal' ? !inList : inList;
|
|
344
|
+
});
|
|
345
|
+
}
|
|
249
346
|
if (category.field === 'amount') {
|
|
250
347
|
// Per-line matching: the transaction is included if ANY of its lines
|
|
251
348
|
// satisfies the operator. This is what the user expects when a
|
|
@@ -52,12 +52,6 @@ export const getReviewPageBillDetail = (state, billId) => {
|
|
|
52
52
|
let recurringConfig;
|
|
53
53
|
let billPayInfo;
|
|
54
54
|
let isBillMarkedForRetry = false;
|
|
55
|
-
// Bill-level accounting class id. Approval Rules 3.0 'department'
|
|
56
|
-
// criteria match against this. Sourced from BillTransaction so
|
|
57
|
-
// any selector that needs it (e.g. creator-as-approver lookup)
|
|
58
|
-
// can read it off the view rather than reaching into
|
|
59
|
-
// 'state.billTransactionState' itself.
|
|
60
|
-
let classId;
|
|
61
55
|
const zeniAssistRetryStatus = billId != null
|
|
62
56
|
? billDetailViewState.billDetailById[key].zeniAssist.retryStatus
|
|
63
57
|
: undefined;
|
|
@@ -68,13 +62,6 @@ export const getReviewPageBillDetail = (state, billId) => {
|
|
|
68
62
|
transaction?.billPayInfo.isCollectToAccountInfoFromVendorContact ?? false;
|
|
69
63
|
isRecurring = transaction?.isRecurring ?? false;
|
|
70
64
|
billPayInfo = transaction?.billPayInfo;
|
|
71
|
-
// Normalise empty-string to undefined so downstream readers
|
|
72
|
-
// treat "no class" uniformly regardless of whether the wire
|
|
73
|
-
// used '' or omitted the field.
|
|
74
|
-
classId =
|
|
75
|
-
transaction?.classId != null && transaction.classId !== ''
|
|
76
|
-
? transaction.classId
|
|
77
|
-
: undefined;
|
|
78
65
|
if (isRecurring &&
|
|
79
66
|
transaction?.recurringBillConfigId != null &&
|
|
80
67
|
transaction.recurringBillInstance != null) {
|
|
@@ -191,6 +178,5 @@ export const getReviewPageBillDetail = (state, billId) => {
|
|
|
191
178
|
zeniAssistRetryStatus,
|
|
192
179
|
billPayInfo,
|
|
193
180
|
outsideZeniPaymentInfo,
|
|
194
|
-
classId,
|
|
195
181
|
};
|
|
196
182
|
};
|
|
@@ -13,7 +13,6 @@ export const initialState = {
|
|
|
13
13
|
newApprovalRuleId: undefined,
|
|
14
14
|
approvalRulesDeleteStatusById: {},
|
|
15
15
|
billPaySetupApproverViewUpdateData: undefined,
|
|
16
|
-
reorderStatus: { fetchState: 'Not-Started', error: undefined },
|
|
17
16
|
hasValidState() {
|
|
18
17
|
return this.fetchState === 'Completed';
|
|
19
18
|
},
|
|
@@ -27,11 +26,8 @@ const billPaySetupApproverView = createSlice({
|
|
|
27
26
|
draft.fetchState = 'In-Progress';
|
|
28
27
|
draft.error = undefined;
|
|
29
28
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// v2 endpoint in the fetch epic.
|
|
33
|
-
prepare(cacheOverride = false, includeUserRoles = true, useV3 = false) {
|
|
34
|
-
return { payload: { cacheOverride, includeUserRoles, useV3 } };
|
|
29
|
+
prepare(cacheOverride = false, includeUserRoles = true) {
|
|
30
|
+
return { payload: { cacheOverride, includeUserRoles } };
|
|
35
31
|
},
|
|
36
32
|
},
|
|
37
33
|
fetchBillPaySetupApproverViewSuccess: {
|
|
@@ -116,11 +112,8 @@ const billPaySetupApproverView = createSlice({
|
|
|
116
112
|
error: undefined,
|
|
117
113
|
};
|
|
118
114
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// can pick the v1 vs v2 endpoint.
|
|
122
|
-
prepare(approvalRuleId, useV3 = false) {
|
|
123
|
-
return { payload: { approvalRuleId, useV3 } };
|
|
115
|
+
prepare(approvalRuleId) {
|
|
116
|
+
return { payload: { approvalRuleId } };
|
|
124
117
|
},
|
|
125
118
|
},
|
|
126
119
|
deleteBillPayApprovalRuleSuccess: {
|
|
@@ -152,96 +145,13 @@ const billPaySetupApproverView = createSlice({
|
|
|
152
145
|
};
|
|
153
146
|
},
|
|
154
147
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
* priorities from the response) or recovers (failure — refetches
|
|
163
|
-
* the view so we don't strand a stale local order).
|
|
164
|
-
*/
|
|
165
|
-
reorderBillPayApprovalRules: {
|
|
166
|
-
reducer(draft, action) {
|
|
167
|
-
const { approvalRuleIds } = action.payload;
|
|
168
|
-
const wasReorderInFlight = draft.reorderStatus.fetchState === 'In-Progress';
|
|
169
|
-
draft.reorderStatus = { fetchState: 'In-Progress', error: undefined };
|
|
170
|
-
// Stash the pre-reorder order so 'Failure' can restore it
|
|
171
|
-
// synchronously. The epic's refetch on failure remains as a
|
|
172
|
-
// safety net (covers cases where the server's truth has
|
|
173
|
-
// drifted from the local snapshot), but the snappy UX path
|
|
174
|
-
// is the in-memory rollback.
|
|
175
|
-
//
|
|
176
|
-
// Only capture a fresh snapshot when no reorder is already in
|
|
177
|
-
// flight. If a second drag fires before the first PUT lands,
|
|
178
|
-
// the existing snapshot already holds the last server-backed
|
|
179
|
-
// order; overwriting it with the first reorder's optimistic
|
|
180
|
-
// result would mean a Failure rolls back to an uncommitted
|
|
181
|
-
// intermediate order instead of the last good list.
|
|
182
|
-
if (!wasReorderInFlight) {
|
|
183
|
-
draft.reorderRollbackIds = draft.approvalRuleIds;
|
|
184
|
-
}
|
|
185
|
-
// Optimistic: render new order immediately. On failure, the
|
|
186
|
-
// reducer restores 'reorderRollbackIds' and the epic refetch
|
|
187
|
-
// reconciles any drift.
|
|
188
|
-
draft.approvalRuleIds = approvalRuleIds;
|
|
189
|
-
},
|
|
190
|
-
prepare(approvalRuleIds, useV3 = false) {
|
|
191
|
-
return { payload: { approvalRuleIds, useV3 } };
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
reorderBillPayApprovalRulesSuccess: {
|
|
195
|
-
reducer(draft, action) {
|
|
196
|
-
const { approvalRuleIds } = action.payload;
|
|
197
|
-
draft.reorderStatus = { fetchState: 'Completed', error: undefined };
|
|
198
|
-
// The API response is authoritative — overwrite with the
|
|
199
|
-
// server's reported order in case it normalised anything.
|
|
200
|
-
draft.approvalRuleIds = approvalRuleIds;
|
|
201
|
-
// Reorder succeeded — discard the snapshot so the next
|
|
202
|
-
// reorder starts from this committed order.
|
|
203
|
-
draft.reorderRollbackIds = undefined;
|
|
204
|
-
},
|
|
205
|
-
prepare(approvalRuleIds) {
|
|
206
|
-
return { payload: { approvalRuleIds } };
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
reorderBillPayApprovalRulesFailure: {
|
|
210
|
-
reducer(draft, action) {
|
|
211
|
-
const { status } = action.payload;
|
|
212
|
-
draft.reorderStatus = { fetchState: 'Error', error: status };
|
|
213
|
-
// Restore the snapshot taken on the trigger reducer before
|
|
214
|
-
// the optimistic mutation. The epic still fires a refetch
|
|
215
|
-
// alongside the failure action for cross-tab drift recovery,
|
|
216
|
-
// but locally the user sees their last good order instantly.
|
|
217
|
-
if (draft.reorderRollbackIds != null) {
|
|
218
|
-
draft.approvalRuleIds = draft.reorderRollbackIds;
|
|
219
|
-
draft.reorderRollbackIds = undefined;
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
prepare(status) {
|
|
223
|
-
return { payload: { status } };
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
saveBillPaySetupApproverViewUpdates: {
|
|
227
|
-
// Approval Rules 3.0 — `useV3` is sourced from the
|
|
228
|
-
// `approval_rule_v3_config` dynamic config in the screen
|
|
229
|
-
// connector. The reducer doesn't read it (the field only
|
|
230
|
-
// matters in the save epic), but it must be declared so the
|
|
231
|
-
// action's payload type is correctly inferred for downstream
|
|
232
|
-
// consumers.
|
|
233
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
234
|
-
reducer(draft, _action) {
|
|
235
|
-
if (draft.billPaySetupApproverViewUpdateData != null) {
|
|
236
|
-
draft.billPaySetupApproverViewUpdateData.updateStatus = {
|
|
237
|
-
fetchState: 'In-Progress',
|
|
238
|
-
error: undefined,
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
|
-
prepare(useV3) {
|
|
243
|
-
return { payload: { useV3 } };
|
|
244
|
-
},
|
|
148
|
+
saveBillPaySetupApproverViewUpdates(draft) {
|
|
149
|
+
if (draft.billPaySetupApproverViewUpdateData != null) {
|
|
150
|
+
draft.billPaySetupApproverViewUpdateData.updateStatus = {
|
|
151
|
+
fetchState: 'In-Progress',
|
|
152
|
+
error: undefined,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
245
155
|
},
|
|
246
156
|
saveBillPaySetupApproverViewUpdatesSuccess: {
|
|
247
157
|
reducer(draft, action) {
|
|
@@ -330,5 +240,5 @@ const billPaySetupApproverView = createSlice({
|
|
|
330
240
|
},
|
|
331
241
|
},
|
|
332
242
|
});
|
|
333
|
-
export const { fetchBillPaySetupApproverView, fetchBillPaySetupApproverViewSuccess, fetchBillPaySetupApproverViewFailure, fetchBillPayApproversDetails, fetchBillPayApproversList, fetchBillPayApproversListSuccess, fetchBillPayApproversListFailure, deleteBillPayApprovalRule, deleteBillPayApprovalRuleSuccess, deleteBillPayApprovalRuleFailure,
|
|
243
|
+
export const { fetchBillPaySetupApproverView, fetchBillPaySetupApproverViewSuccess, fetchBillPaySetupApproverViewFailure, fetchBillPayApproversDetails, fetchBillPayApproversList, fetchBillPayApproversListSuccess, fetchBillPayApproversListFailure, deleteBillPayApprovalRule, deleteBillPayApprovalRuleSuccess, deleteBillPayApprovalRuleFailure, saveBillPaySetupApproverViewUpdates, saveBillPaySetupApproverViewUpdatesSuccess, saveBillPaySetupApproverViewUpdatesFailure, initializeBillPaySetupApproverViewUpdateData, saveBillPaySetupApproverViewUpdateData, clearBillPaySetupApproverViewUpdateData, setListeningToPusherEvent, clearBillPaySetupApproverView, } = billPaySetupApproverView.actions;
|
|
334
244
|
export default billPaySetupApproverView.reducer;
|
|
@@ -6,17 +6,9 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { deleteBillPayApprovalRule, deleteBillPayApprovalRuleFailure, deleteBillPayApprovalRuleSuccess, } from '../billPaySetupApproverViewReducer';
|
|
8
8
|
export const deleteBillPayApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteBillPayApprovalRule.match), switchMap((action) => {
|
|
9
|
-
const { approvalRuleId
|
|
10
|
-
// Approval Rules 3.0 — flag-gated endpoint selection.
|
|
11
|
-
// Explicit `=== true` keeps `strict-boolean-expressions` happy
|
|
12
|
-
// when RTK's payload type widens to `any` in some configs.
|
|
13
|
-
const endpoint = useV3 === true
|
|
14
|
-
? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
|
|
15
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
|
|
9
|
+
const { approvalRuleId } = action.payload;
|
|
16
10
|
return zeniAPI
|
|
17
|
-
.deleteAndGetJSON(
|
|
18
|
-
approval_rule_id: approvalRuleId,
|
|
19
|
-
})
|
|
11
|
+
.deleteAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`, { approval_rule_id: approvalRuleId })
|
|
20
12
|
.pipe(mergeMap((response) => {
|
|
21
13
|
if (isSuccessResponse(response) && response.data != null) {
|
|
22
14
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
@@ -6,7 +6,7 @@ import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { fetchBillPaySetupApproverView, fetchBillPaySetupApproverViewFailure, fetchBillPaySetupApproverViewSuccess, } from '../billPaySetupApproverViewReducer';
|
|
8
8
|
export const fetchBillPaySetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchBillPaySetupApproverView.match), switchMap((action) => {
|
|
9
|
-
const { cacheOverride
|
|
9
|
+
const { cacheOverride } = action.payload;
|
|
10
10
|
const { billPaySetupApproverViewState, approvalRuleState } = state$.value;
|
|
11
11
|
const approvalRules = getApprovalRulesByIds(approvalRuleState, billPaySetupApproverViewState.approvalRuleIds);
|
|
12
12
|
if (cacheOverride === true ||
|
|
@@ -14,13 +14,9 @@ export const fetchBillPaySetupApproverViewEpic = (actions$, state$, zeniAPI) =>
|
|
|
14
14
|
billPaySetupApproverViewState.approvalRuleIds.length ||
|
|
15
15
|
(billPaySetupApproverViewState.hasValidState() === false &&
|
|
16
16
|
billPaySetupApproverViewState.fetchState !== 'In-Progress')) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const endpoint = useV3 === true
|
|
21
|
-
? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
|
|
22
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
|
|
23
|
-
return zeniAPI.getJSON(endpoint).pipe(mergeMap((response) => {
|
|
17
|
+
return zeniAPI
|
|
18
|
+
.getJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`)
|
|
19
|
+
.pipe(mergeMap((response) => {
|
|
24
20
|
if (isSuccessResponse(response) && response.data != null) {
|
|
25
21
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|
|
26
22
|
const actions = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { from } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
-
import {
|
|
3
|
+
import { getApprovalRuleById } from '../../../../../entity/approvalRule/approvalRuleSelector';
|
|
4
4
|
import { clearBillPaySetupApproverViewUpdateData, initializeBillPaySetupApproverViewUpdateData, saveBillPaySetupApproverViewUpdateData, } from '../billPaySetupApproverViewReducer';
|
|
5
5
|
export const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state$) => actions$.pipe(filter(initializeBillPaySetupApproverViewUpdateData.match), mergeMap((action) => {
|
|
6
6
|
const { approvalRuleId } = action.payload;
|
|
@@ -8,20 +8,16 @@ export const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state
|
|
|
8
8
|
if (approvalRuleId != null) {
|
|
9
9
|
const approvalRule = getApprovalRuleById(state$.value.approvalRuleState, approvalRuleId);
|
|
10
10
|
if (approvalRule != null) {
|
|
11
|
+
const criteria = approvalRule.criteria[0];
|
|
12
|
+
const range = criteria?.range;
|
|
11
13
|
const billPaySetupApproverViewUpdateData = {
|
|
12
14
|
approvalRuleId,
|
|
13
15
|
steps: approvalRule.steps,
|
|
14
16
|
criteria: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
rangeType: criteria?.rangeType,
|
|
18
|
+
rangeEntity: criteria?.rangeEntity,
|
|
19
|
+
range,
|
|
18
20
|
},
|
|
19
|
-
// Approval Rules 3.0 — seed rule-level fields so the form can
|
|
20
|
-
// round-trip them on edit. Each may be undefined on legacy rules.
|
|
21
|
-
name: approvalRule.name,
|
|
22
|
-
description: approvalRule.description,
|
|
23
|
-
separationOfDuties: approvalRule.separationOfDuties,
|
|
24
|
-
isFallback: approvalRule.isFallback,
|
|
25
21
|
};
|
|
26
22
|
fetchActions.push(clearBillPaySetupApproverViewUpdateData(), saveBillPaySetupApproverViewUpdateData(billPaySetupApproverViewUpdateData));
|
|
27
23
|
}
|
|
@@ -29,7 +25,7 @@ export const initializeBillPaySetupApproverViewUpdateDataEpic = (actions$, state
|
|
|
29
25
|
else {
|
|
30
26
|
const billPaySetupApproverViewCreateData = {
|
|
31
27
|
steps: [],
|
|
32
|
-
criteria:
|
|
28
|
+
criteria: undefined,
|
|
33
29
|
};
|
|
34
30
|
fetchActions.push(clearBillPaySetupApproverViewUpdateData(), saveBillPaySetupApproverViewUpdateData(billPaySetupApproverViewCreateData));
|
|
35
31
|
}
|
|
@@ -5,24 +5,15 @@ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
|
|
|
5
5
|
import { updateAllUsers } from '../../../../../entity/user/userReducer';
|
|
6
6
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
7
7
|
import { saveBillPaySetupApproverViewUpdates, saveBillPaySetupApproverViewUpdatesFailure, saveBillPaySetupApproverViewUpdatesSuccess, } from '../billPaySetupApproverViewReducer';
|
|
8
|
-
import { toApprovalChangableInfoPayload
|
|
9
|
-
export const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveBillPaySetupApproverViewUpdates.match), switchMap((
|
|
8
|
+
import { toApprovalChangableInfoPayload } from '../types/commonPayload';
|
|
9
|
+
export const saveBillPaySetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(saveBillPaySetupApproverViewUpdates.match), switchMap(() => {
|
|
10
10
|
const { billPaySetupApproverViewState } = state$.value;
|
|
11
11
|
const billPaySetupApproverViewUpdateData = billPaySetupApproverViewState.billPaySetupApproverViewUpdateData;
|
|
12
12
|
if (billPaySetupApproverViewUpdateData != null &&
|
|
13
13
|
billPaySetupApproverViewUpdateData.data != null) {
|
|
14
|
-
|
|
15
|
-
// the `approval_rule_v3_config` dynamic config. `useV3` arrives
|
|
16
|
-
// on the action payload from the screen connector.
|
|
17
|
-
const { useV3 } = action.payload;
|
|
18
|
-
const payload = useV3
|
|
19
|
-
? toApprovalChangableInfoPayload(billPaySetupApproverViewUpdateData.data)
|
|
20
|
-
: toApprovalChangableInfoPayloadV1(billPaySetupApproverViewUpdateData.data);
|
|
21
|
-
const endpoint = useV3
|
|
22
|
-
? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`
|
|
23
|
-
: `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;
|
|
14
|
+
const payload = toApprovalChangableInfoPayload(billPaySetupApproverViewUpdateData.data);
|
|
24
15
|
return zeniAPI
|
|
25
|
-
.postAndGetJSON(
|
|
16
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`, payload)
|
|
26
17
|
.pipe(mergeMap((response) => {
|
|
27
18
|
if (isSuccessResponse(response) && response.data != null) {
|
|
28
19
|
const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
|