@zeniai/client-epic-state 5.2.89-beta0KB → 5.2.89-beta0MM

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 (66) hide show
  1. package/lib/entity/invoicing/creditNote/creditNotePayload.d.ts +2 -0
  2. package/lib/entity/invoicing/creditNote/creditNotePayload.js +5 -0
  3. package/lib/entity/invoicing/creditNote/creditNoteState.d.ts +1 -0
  4. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  5. package/lib/entity/snackbar/snackbarTypes.js +0 -1
  6. package/lib/entity/transaction/stateTypes/paymentType.d.ts +2 -2
  7. package/lib/entity/transaction/stateTypes/paymentType.js +1 -9
  8. package/lib/epic.d.ts +1 -5
  9. package/lib/epic.js +0 -8
  10. package/lib/esm/entity/invoicing/creditNote/creditNotePayload.js +5 -0
  11. package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
  12. package/lib/esm/entity/transaction/stateTypes/paymentType.js +1 -9
  13. package/lib/esm/epic.js +0 -8
  14. package/lib/esm/index.js +2 -5
  15. package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +1 -0
  16. package/lib/esm/view/financeStatement/financeStatementReducer.js +6 -11
  17. package/lib/esm/view/invoicing/invoicingOverview/invoicingOverviewPayload.js +1 -0
  18. package/lib/esm/view/reportUIOptions/financeStatementCompareBalances.js +16 -0
  19. package/lib/esm/view/reportUIOptions/updateReportUIOptionCompareModeEpic.js +2 -5
  20. package/lib/esm/view/reportUIOptions/updateReportUIOptionIsCompareModeOnEpic.js +6 -10
  21. package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -196
  22. package/lib/index.d.ts +2 -6
  23. package/lib/index.js +37 -58
  24. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
  25. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +1 -0
  26. package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +1 -0
  27. package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +2 -0
  28. package/lib/view/financeStatement/financeStatementReducer.js +6 -11
  29. package/lib/view/invoicing/invoicingOverview/invoicingOverviewPayload.d.ts +5 -0
  30. package/lib/view/invoicing/invoicingOverview/invoicingOverviewPayload.js +1 -0
  31. package/lib/view/invoicing/invoicingOverview/invoicingOverviewState.d.ts +2 -0
  32. package/lib/view/reportUIOptions/financeStatementCompareBalances.d.ts +2 -0
  33. package/lib/view/reportUIOptions/financeStatementCompareBalances.js +19 -0
  34. package/lib/view/reportUIOptions/updateReportUIOptionCompareModeEpic.js +2 -5
  35. package/lib/view/reportUIOptions/updateReportUIOptionIsCompareModeOnEpic.js +6 -10
  36. package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -39
  37. package/lib/view/transactionDetail/transactionDetailReducer.js +2 -198
  38. package/lib/view/transactionDetail/transactionDetailState.d.ts +0 -12
  39. package/package.json +1 -1
  40. package/lib/entity/transaction/stateTypes/printStatus.d.ts +0 -4
  41. package/lib/entity/transaction/stateTypes/printStatus.js +0 -11
  42. package/lib/esm/entity/transaction/stateTypes/printStatus.js +0 -7
  43. package/lib/esm/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +0 -157
  44. package/lib/esm/view/transactionDetail/createTransaction/createTransactionPayload.js +0 -164
  45. package/lib/esm/view/transactionDetail/createTransaction/createTransactionSelector.js +0 -47
  46. package/lib/esm/view/transactionDetail/createTransaction/createTransactionState.js +0 -11
  47. package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +0 -19
  48. package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +0 -81
  49. package/lib/esm/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +0 -53
  50. package/lib/esm/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +0 -10
  51. package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.d.ts +0 -56
  52. package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +0 -172
  53. package/lib/view/transactionDetail/createTransaction/createTransactionPayload.d.ts +0 -95
  54. package/lib/view/transactionDetail/createTransaction/createTransactionPayload.js +0 -169
  55. package/lib/view/transactionDetail/createTransaction/createTransactionSelector.d.ts +0 -44
  56. package/lib/view/transactionDetail/createTransaction/createTransactionSelector.js +0 -53
  57. package/lib/view/transactionDetail/createTransaction/createTransactionState.d.ts +0 -82
  58. package/lib/view/transactionDetail/createTransaction/createTransactionState.js +0 -14
  59. package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.d.ts +0 -10
  60. package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +0 -23
  61. package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.d.ts +0 -9
  62. package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +0 -85
  63. package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.d.ts +0 -20
  64. package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +0 -57
  65. package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.d.ts +0 -12
  66. package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +0 -14
@@ -1,9 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
4
- import { updateTransaction } from '../../../../entity/transaction/transactionReducer';
5
- import { RootState } from '../../../../rootStateTypes';
6
- import { ZeniAPI } from '../../../../zeniAPI';
7
- import { createTransaction, createTransactionSuccessOrFailure, initializeTransactionDetailLocalData } from '../../transactionDetailReducer';
8
- export type ActionType = ReturnType<typeof createTransaction> | ReturnType<typeof createTransactionSuccessOrFailure> | ReturnType<typeof initializeTransactionDetailLocalData> | ReturnType<typeof updateTransaction> | ReturnType<typeof openSnackbar>;
9
- export declare const createTransactionEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTransactionEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
7
- const transactionIDPayload_1 = require("../../../../entity/transaction/payloadTypes/transactionIDPayload");
8
- const transactionReducer_1 = require("../../../../entity/transaction/transactionReducer");
9
- const responsePayload_1 = require("../../../../responsePayload");
10
- const transactionDetailReducer_1 = require("../../transactionDetailReducer");
11
- const transactionDetailState_1 = require("../../transactionDetailState");
12
- const createTransactionPayload_1 = require("../createTransactionPayload");
13
- const createTransactionEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(transactionDetailReducer_1.createTransaction.match),
14
- // exhaustMap, not mergeMap: a second submit while one is in flight is dropped here rather
15
- // than relying only on the disabled Save button, so it cannot create a duplicate in QBO.
16
- (0, operators_1.exhaustMap)((action) => {
17
- const { transactionType } = action.payload;
18
- const state = state$.value;
19
- const localData = state.transactionDetailState.createTransactionsState
20
- .newTransactionState[transactionType];
21
- // Deferred so a payload that cannot be built (an id with no QBO id) lands in catchError
22
- // below as a failure, instead of throwing out of the epic.
23
- return (0, rxjs_1.defer)(() => zeniAPI.postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/manage`, (0, createTransactionPayload_1.prepareCreateTransactionPayload)(state, localData))).pipe((0, operators_1.mergeMap)((response) => {
24
- const created = (0, responsePayload_1.isSuccessResponse)(response)
25
- ? response.data?.transactions[0]
26
- : undefined;
27
- if (created == null) {
28
- const status = (0, responsePayload_1.isSuccessResponse)(response)
29
- ? (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Transaction was created but returned no details.')
30
- : response.status;
31
- return (0, rxjs_1.from)([
32
- (0, transactionDetailReducer_1.createTransactionSuccessOrFailure)('Error', undefined, status),
33
- (0, snackbarReducer_1.openSnackbar)({
34
- messageSection: 'create_transaction',
35
- messageText: 'failed',
36
- type: 'error',
37
- // This variable is how the server's own message reaches the user. Per-type
38
- // required fields live in the QBO entity classes, so a rejection comes back as a
39
- // QBO error with no field name -- the message text is the only useful content.
40
- variables: [
41
- { variableName: '_api-error_', variableValue: status.message },
42
- ],
43
- }),
44
- ]);
45
- }
46
- const newTransactionId = (0, transactionIDPayload_1.toTransactionID)(created);
47
- // The write is QBO-only: transaction_write_handler.py touches no local storage, and
48
- // Zeni's mirror is populated by the delta sync that runs afterwards. Refetching here
49
- // would come back without the new row, so the 200 body is inserted optimistically
50
- // instead -- the same approach createTransferEntryEpic takes.
51
- return (0, rxjs_1.from)([
52
- (0, transactionReducer_1.updateTransaction)((0, transactionDetailState_1.getTransactionDetailKey)(newTransactionId), created),
53
- // No reset here: it would clear createdTransactionId in the same tick, before the
54
- // screen renders it to upload pending attachments and navigate. The screen resets
55
- // the working copy on unmount instead.
56
- // Before the local-data init: it seeds the detail entry that init writes into.
57
- (0, transactionDetailReducer_1.createTransactionSuccessOrFailure)('Completed', newTransactionId),
58
- (0, transactionDetailReducer_1.initializeTransactionDetailLocalData)({
59
- transactionId: newTransactionId,
60
- vendorId: created.vendor_id ?? undefined,
61
- }),
62
- (0, snackbarReducer_1.openSnackbar)({
63
- messageSection: 'create_transaction',
64
- messageText: 'success',
65
- type: 'success',
66
- }),
67
- ]);
68
- }), (0, operators_1.catchError)((error) => {
69
- const message = error instanceof createTransactionPayload_1.UnresolvedCreateTransactionIdError
70
- ? error.message
71
- : JSON.stringify(error);
72
- return (0, rxjs_1.from)([
73
- (0, transactionDetailReducer_1.createTransactionSuccessOrFailure)('Error', undefined, (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', `Create Transaction REST API call errored out ${message}`)),
74
- (0, snackbarReducer_1.openSnackbar)({
75
- messageSection: 'create_transaction',
76
- messageText: 'failed',
77
- type: 'error',
78
- variables: [
79
- { variableName: '_api-error_', variableValue: message },
80
- ],
81
- }),
82
- ]);
83
- }));
84
- }));
85
- exports.createTransactionEpic = createTransactionEpic;
@@ -1,20 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { RootState } from '../../../../rootStateTypes';
4
- import { fetchRecommendationByEntityId, fetchRecommendationByEntityName, indicateReadyToInitializeRecommendation } from '../../../recommendation/recommendationReducer';
5
- import { clearRecommendationsForCreateTransactionLines, fetchVendorRecommendationsForCreateTransaction, setRecommendationsForCreateTransactionLines } from '../../transactionDetailReducer';
6
- export type ActionType = ReturnType<typeof fetchVendorRecommendationsForCreateTransaction> | ReturnType<typeof setRecommendationsForCreateTransactionLines> | ReturnType<typeof clearRecommendationsForCreateTransactionLines> | ReturnType<typeof fetchRecommendationByEntityId> | ReturnType<typeof fetchRecommendationByEntityName> | ReturnType<typeof indicateReadyToInitializeRecommendation>;
7
- /**
8
- * On vendor select, populates the category/class dropdowns from that vendor's recommendations.
9
- *
10
- * Deliberately NOT the detail page's fetchEntityRecommendationsForLineUpdate: that one sends
11
- * transaction_id / line_ids and writes into transactionDetailById[key], which no-ops when the
12
- * entry does not exist. A transaction being created has neither.
13
- *
14
- * Two differences from the reimbursement epic this is modelled on:
15
- * 1. the wait filters on the matching entityIdOrName before take(1), so an unrelated
16
- * recommendation landing first cannot satisfy this request, and
17
- * 2. switchMap, so changing the vendor again cancels the earlier wait rather than letting a
18
- * stale result overwrite the newer vendor's prefill.
19
- */
20
- export declare const fetchVendorRecommendationsForCreateTransactionEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchVendorRecommendationsForCreateTransactionEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
7
- const recommendationReducer_1 = require("../../../recommendation/recommendationReducer");
8
- const recommendationSelector_1 = require("../../../recommendation/recommendationSelector");
9
- const transactionDetailReducer_1 = require("../../transactionDetailReducer");
10
- /**
11
- * The entity-level recommendation fetch, keyed by whatever identifier the endpoint can resolve.
12
- *
13
- * A vendor that has not synced to QBO carries `qboId === name`; the id endpoint has nothing to
14
- * look up in that case, so the by-name variant is used instead.
15
- */
16
- const toEntityIdOrName = (entity) => entity.qboId && entity.qboId !== entity.name ? entity.qboId : entity.name;
17
- const isUnsyncedVendor = (entity) => !entity.qboId || entity.qboId === entity.name;
18
- /**
19
- * On vendor select, populates the category/class dropdowns from that vendor's recommendations.
20
- *
21
- * Deliberately NOT the detail page's fetchEntityRecommendationsForLineUpdate: that one sends
22
- * transaction_id / line_ids and writes into transactionDetailById[key], which no-ops when the
23
- * entry does not exist. A transaction being created has neither.
24
- *
25
- * Two differences from the reimbursement epic this is modelled on:
26
- * 1. the wait filters on the matching entityIdOrName before take(1), so an unrelated
27
- * recommendation landing first cannot satisfy this request, and
28
- * 2. switchMap, so changing the vendor again cancels the earlier wait rather than letting a
29
- * stale result overwrite the newer vendor's prefill.
30
- */
31
- const fetchVendorRecommendationsForCreateTransactionEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(transactionDetailReducer_1.fetchVendorRecommendationsForCreateTransaction.match), (0, operators_1.switchMap)((action) => {
32
- const { transactionType, entity, lineIds } = action.payload;
33
- if (entity == null) {
34
- return (0, rxjs_1.of)((0, transactionDetailReducer_1.clearRecommendationsForCreateTransactionLines)(transactionType, lineIds));
35
- }
36
- const entityIdOrName = toEntityIdOrName(entity);
37
- const state = state$.value;
38
- const isAccountingClassesEnabled = (0, tenantSelector_1.getIsAccountingClassesEnabled)(state);
39
- const cached = (0, recommendationSelector_1.getRecommendationsForEntity)(state, entityIdOrName, 'vendor');
40
- // Cache hit: apply straight away, no request and no wait.
41
- if (cached.fetchState === 'Completed') {
42
- return (0, rxjs_1.of)((0, transactionDetailReducer_1.setRecommendationsForCreateTransactionLines)(transactionType, lineIds, cached.recommendations ?? [], isAccountingClassesEnabled));
43
- }
44
- const waitThenApply = actions$.pipe((0, operators_1.filter)(recommendationReducer_1.indicateReadyToInitializeRecommendation.match), (0, operators_1.filter)((ready) => ready.payload.entityType === 'vendor' &&
45
- ready.payload.entityIdOrName === entityIdOrName), (0, operators_1.take)(1), // don't listen forever! IMPORTANT!
46
- (0, operators_1.mergeMap)(() => (0, rxjs_1.from)([
47
- (0, transactionDetailReducer_1.setRecommendationsForCreateTransactionLines)(transactionType, lineIds, (0, recommendationSelector_1.getRecommendationsForEntity)(state$.value, entityIdOrName, 'vendor').recommendations ?? [], (0, tenantSelector_1.getIsAccountingClassesEnabled)(state$.value)),
48
- ])));
49
- // A fetch already in flight needs no second request, only the wait.
50
- if (cached.fetchState === 'In-Progress') {
51
- return waitThenApply;
52
- }
53
- return (0, rxjs_1.concat)((0, rxjs_1.of)((isUnsyncedVendor(entity)
54
- ? (0, recommendationReducer_1.fetchRecommendationByEntityName)(entityIdOrName, 'vendor')
55
- : (0, recommendationReducer_1.fetchRecommendationByEntityId)(entityIdOrName, 'vendor'))), waitThenApply);
56
- }));
57
- exports.fetchVendorRecommendationsForCreateTransactionEpic = fetchVendorRecommendationsForCreateTransactionEpic;
@@ -1,12 +0,0 @@
1
- import { ActionsObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { initializeCreateTransactionLocalData, resetCreateTransactionLocalData } from '../../transactionDetailReducer';
4
- export type ActionType = ReturnType<typeof initializeCreateTransactionLocalData> | ReturnType<typeof resetCreateTransactionLocalData>;
5
- /**
6
- * Seeds the working copy when the Create form opens: today's date, the default line set for the
7
- * type, and the payment_type the backend insists on.
8
- *
9
- * The seed replaces the whole working copy rather than merging into it, so a second initialize
10
- * for the same type can't leave the previous draft's vendor, memo or account behind.
11
- */
12
- export declare const initializeCreateTransactionLocalDataEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initializeCreateTransactionLocalDataEpic = void 0;
4
- const operators_1 = require("rxjs/operators");
5
- const transactionDetailReducer_1 = require("../../transactionDetailReducer");
6
- /**
7
- * Seeds the working copy when the Create form opens: today's date, the default line set for the
8
- * type, and the payment_type the backend insists on.
9
- *
10
- * The seed replaces the whole working copy rather than merging into it, so a second initialize
11
- * for the same type can't leave the previous draft's vendor, memo or account behind.
12
- */
13
- const initializeCreateTransactionLocalDataEpic = (actions$) => actions$.pipe((0, operators_1.filter)(transactionDetailReducer_1.initializeCreateTransactionLocalData.match), (0, operators_1.map)((action) => (0, transactionDetailReducer_1.resetCreateTransactionLocalData)(action.payload.transactionType)));
14
- exports.initializeCreateTransactionLocalDataEpic = initializeCreateTransactionLocalDataEpic;