@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.
- package/lib/entity/invoicing/creditNote/creditNotePayload.d.ts +2 -0
- package/lib/entity/invoicing/creditNote/creditNotePayload.js +5 -0
- package/lib/entity/invoicing/creditNote/creditNoteState.d.ts +1 -0
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/entity/transaction/stateTypes/paymentType.d.ts +2 -2
- package/lib/entity/transaction/stateTypes/paymentType.js +1 -9
- package/lib/epic.d.ts +1 -5
- package/lib/epic.js +0 -8
- package/lib/esm/entity/invoicing/creditNote/creditNotePayload.js +5 -0
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -1
- package/lib/esm/entity/transaction/stateTypes/paymentType.js +1 -9
- package/lib/esm/epic.js +0 -8
- package/lib/esm/index.js +2 -5
- package/lib/esm/view/expenseAutomationView/payload/actualMatchingPayload.js +1 -0
- package/lib/esm/view/financeStatement/financeStatementReducer.js +6 -11
- package/lib/esm/view/invoicing/invoicingOverview/invoicingOverviewPayload.js +1 -0
- package/lib/esm/view/reportUIOptions/financeStatementCompareBalances.js +16 -0
- package/lib/esm/view/reportUIOptions/updateReportUIOptionCompareModeEpic.js +2 -5
- package/lib/esm/view/reportUIOptions/updateReportUIOptionIsCompareModeOnEpic.js +6 -10
- package/lib/esm/view/transactionDetail/transactionDetailReducer.js +1 -196
- package/lib/index.d.ts +2 -6
- package/lib/index.js +37 -58
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/expenseAutomationView/payload/actualMatchingPayload.d.ts +1 -0
- package/lib/view/expenseAutomationView/payload/actualMatchingPayload.js +1 -0
- package/lib/view/expenseAutomationView/types/actualMatchingViewState.d.ts +2 -0
- package/lib/view/financeStatement/financeStatementReducer.js +6 -11
- package/lib/view/invoicing/invoicingOverview/invoicingOverviewPayload.d.ts +5 -0
- package/lib/view/invoicing/invoicingOverview/invoicingOverviewPayload.js +1 -0
- package/lib/view/invoicing/invoicingOverview/invoicingOverviewState.d.ts +2 -0
- package/lib/view/reportUIOptions/financeStatementCompareBalances.d.ts +2 -0
- package/lib/view/reportUIOptions/financeStatementCompareBalances.js +19 -0
- package/lib/view/reportUIOptions/updateReportUIOptionCompareModeEpic.js +2 -5
- package/lib/view/reportUIOptions/updateReportUIOptionIsCompareModeOnEpic.js +6 -10
- package/lib/view/transactionDetail/transactionDetailReducer.d.ts +1 -39
- package/lib/view/transactionDetail/transactionDetailReducer.js +2 -198
- package/lib/view/transactionDetail/transactionDetailState.d.ts +0 -12
- package/package.json +1 -1
- package/lib/entity/transaction/stateTypes/printStatus.d.ts +0 -4
- package/lib/entity/transaction/stateTypes/printStatus.js +0 -11
- package/lib/esm/entity/transaction/stateTypes/printStatus.js +0 -7
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +0 -157
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionPayload.js +0 -164
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionSelector.js +0 -47
- package/lib/esm/view/transactionDetail/createTransaction/createTransactionState.js +0 -11
- package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +0 -19
- package/lib/esm/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +0 -81
- package/lib/esm/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +0 -53
- package/lib/esm/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +0 -10
- package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.d.ts +0 -56
- package/lib/view/transactionDetail/createTransaction/createTransactionLocalDataHelper.js +0 -172
- package/lib/view/transactionDetail/createTransaction/createTransactionPayload.d.ts +0 -95
- package/lib/view/transactionDetail/createTransaction/createTransactionPayload.js +0 -169
- package/lib/view/transactionDetail/createTransaction/createTransactionSelector.d.ts +0 -44
- package/lib/view/transactionDetail/createTransaction/createTransactionSelector.js +0 -53
- package/lib/view/transactionDetail/createTransaction/createTransactionState.d.ts +0 -82
- package/lib/view/transactionDetail/createTransaction/createTransactionState.js +0 -14
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.d.ts +0 -10
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionAttachmentUploadFailureEpic.js +0 -23
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.d.ts +0 -9
- package/lib/view/transactionDetail/createTransaction/epics/createTransactionEpic.js +0 -85
- package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.d.ts +0 -20
- package/lib/view/transactionDetail/createTransaction/epics/fetchVendorRecommendationsForCreateTransactionEpic.js +0 -57
- package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.d.ts +0 -12
- package/lib/view/transactionDetail/createTransaction/epics/initializeCreateTransactionLocalDataEpic.js +0 -14
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.clearRecommendationsFromCreateTransactionLine = exports.applyRecommendationsToCreateTransactionLine = exports.toRecommendationsWithCOT = exports.updateCreateTransactionLine = exports.mergeCreateTransactionLocalData = exports.getSeededCreateTransactionLocalData = exports.getInitialCreateTransactionLocalDataByType = exports.getEmptyCreateTransactionLocalData = exports.getDefaultCreateTransactionLines = exports.createEmptyCreateTransactionLine = exports.resetCreateTransactionLineIdCounter = exports.nextCreateTransactionLineId = void 0;
|
|
4
|
-
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
5
|
-
const createTransactionState_1 = require("./createTransactionState");
|
|
6
|
-
/**
|
|
7
|
-
* Monotonic counter for line row keys. These never leave the client -- the payload builder
|
|
8
|
-
* drops them -- so a counter is enough, and it keeps reducer tests deterministic in a way
|
|
9
|
-
* randomUUID would not.
|
|
10
|
-
*/
|
|
11
|
-
let lineIdCounter = 0;
|
|
12
|
-
const nextCreateTransactionLineId = () => `create-transaction-line-${lineIdCounter++}`;
|
|
13
|
-
exports.nextCreateTransactionLineId = nextCreateTransactionLineId;
|
|
14
|
-
/** Test-only: makes line ids predictable from the start of each case. */
|
|
15
|
-
const resetCreateTransactionLineIdCounter = () => {
|
|
16
|
-
lineIdCounter = 0;
|
|
17
|
-
};
|
|
18
|
-
exports.resetCreateTransactionLineIdCounter = resetCreateTransactionLineIdCounter;
|
|
19
|
-
const createEmptyCreateTransactionLine = (postingType) => ({
|
|
20
|
-
id: (0, exports.nextCreateTransactionLineId)(),
|
|
21
|
-
postingType,
|
|
22
|
-
});
|
|
23
|
-
exports.createEmptyCreateTransactionLine = createEmptyCreateTransactionLine;
|
|
24
|
-
/**
|
|
25
|
-
* The lines a freshly-opened form starts with. A journal entry is invalid with fewer than one
|
|
26
|
-
* debit and one credit, so it opens with both rather than making the user add the second row.
|
|
27
|
-
* Transfer has no lines at all.
|
|
28
|
-
*/
|
|
29
|
-
const getDefaultCreateTransactionLines = (transactionType) => {
|
|
30
|
-
if (transactionType === 'transfer') {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
if (transactionType === 'journal_entry') {
|
|
34
|
-
return [
|
|
35
|
-
(0, exports.createEmptyCreateTransactionLine)('debit'),
|
|
36
|
-
(0, exports.createEmptyCreateTransactionLine)('credit'),
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
return [(0, exports.createEmptyCreateTransactionLine)()];
|
|
40
|
-
};
|
|
41
|
-
exports.getDefaultCreateTransactionLines = getDefaultCreateTransactionLines;
|
|
42
|
-
/**
|
|
43
|
-
* A blank working copy for one type. Note this does NOT seed the date -- the reducer's initial
|
|
44
|
-
* state has to stay a pure constant so `clearAll` restores something stable. The date is seeded
|
|
45
|
-
* by initializeCreateTransactionLocalDataEpic, which runs when the form opens.
|
|
46
|
-
*/
|
|
47
|
-
const getEmptyCreateTransactionLocalData = (transactionType) => ({
|
|
48
|
-
lines: [],
|
|
49
|
-
transactionType,
|
|
50
|
-
});
|
|
51
|
-
exports.getEmptyCreateTransactionLocalData = getEmptyCreateTransactionLocalData;
|
|
52
|
-
const getInitialCreateTransactionLocalDataByType = () => createTransactionState_1.ALL_CREATABLE_TRANSACTION_TYPES.reduce((acc, transactionType) => {
|
|
53
|
-
acc[transactionType] =
|
|
54
|
-
(0, exports.getEmptyCreateTransactionLocalData)(transactionType);
|
|
55
|
-
return acc;
|
|
56
|
-
}, {});
|
|
57
|
-
exports.getInitialCreateTransactionLocalDataByType = getInitialCreateTransactionLocalDataByType;
|
|
58
|
-
/**
|
|
59
|
-
* The payment_type the backend insists on for some types: a check needs `check`, and a
|
|
60
|
-
* credit_card_credit (sent as expense + is_credit) needs a card type -- qbo_purchase.py raises
|
|
61
|
-
* without them.
|
|
62
|
-
*/
|
|
63
|
-
const SEEDED_PAYMENT_TYPE = {
|
|
64
|
-
check: 'check',
|
|
65
|
-
credit_card_credit: 'credit_card',
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* What the form opens with: a blank copy plus today's date, the default line set, and the
|
|
69
|
-
* payment_type the backend insists on for the type.
|
|
70
|
-
*/
|
|
71
|
-
const getSeededCreateTransactionLocalData = (transactionType) => ({
|
|
72
|
-
...(0, exports.getEmptyCreateTransactionLocalData)(transactionType),
|
|
73
|
-
lines: (0, exports.getDefaultCreateTransactionLines)(transactionType),
|
|
74
|
-
paymentType: SEEDED_PAYMENT_TYPE[transactionType],
|
|
75
|
-
transactionDate: (0, zeniDayJS_1.dateNow)(),
|
|
76
|
-
});
|
|
77
|
-
exports.getSeededCreateTransactionLocalData = getSeededCreateTransactionLocalData;
|
|
78
|
-
/**
|
|
79
|
-
* Merges a partial edit into the working copy. Lines are replaced wholesale when present --
|
|
80
|
-
* a partial line array would silently truncate the form.
|
|
81
|
-
*/
|
|
82
|
-
const mergeCreateTransactionLocalData = (current, update) => ({
|
|
83
|
-
...current,
|
|
84
|
-
...update,
|
|
85
|
-
lines: update.lines ?? current.lines,
|
|
86
|
-
// The type is keyed by the slice, never edited through a merge.
|
|
87
|
-
transactionType: current.transactionType,
|
|
88
|
-
});
|
|
89
|
-
exports.mergeCreateTransactionLocalData = mergeCreateTransactionLocalData;
|
|
90
|
-
/**
|
|
91
|
-
* A user edit to a prefilled account or class makes it theirs, so its flag is dropped and a
|
|
92
|
-
* later vendor switch no longer clears it.
|
|
93
|
-
*/
|
|
94
|
-
const updateCreateTransactionLine = (lines, lineId, update) => lines.map((line) => line.id === lineId
|
|
95
|
-
? {
|
|
96
|
-
...line,
|
|
97
|
-
...update,
|
|
98
|
-
id: line.id,
|
|
99
|
-
isAccountPreFilled: 'accountQboId' in update ? undefined : line.isAccountPreFilled,
|
|
100
|
-
isClassPreFilled: 'classId' in update ? undefined : line.isClassPreFilled,
|
|
101
|
-
}
|
|
102
|
-
: line);
|
|
103
|
-
exports.updateCreateTransactionLine = updateCreateTransactionLine;
|
|
104
|
-
/**
|
|
105
|
-
* Recommendation -> RecommendationWithCOT. Chain-of-thought and recommendation feedback both
|
|
106
|
-
* need an existing transaction, so cot/reasoning are empty here by design; the dropdown only
|
|
107
|
-
* needs the entities to build its "Recommended" group.
|
|
108
|
-
*/
|
|
109
|
-
const toRecommendationsWithCOT = (recommendations) => recommendations.map((recommendation) => ({
|
|
110
|
-
account: recommendation.account != null
|
|
111
|
-
? { ...recommendation.account, cot: [], reasoning: '' }
|
|
112
|
-
: undefined,
|
|
113
|
-
class: recommendation.class != null
|
|
114
|
-
? { ...recommendation.class, cot: [], reasoning: '' }
|
|
115
|
-
: undefined,
|
|
116
|
-
vendor: recommendation.vendor != null
|
|
117
|
-
? { ...recommendation.vendor, cot: [], reasoning: '' }
|
|
118
|
-
: undefined,
|
|
119
|
-
}));
|
|
120
|
-
exports.toRecommendationsWithCOT = toRecommendationsWithCOT;
|
|
121
|
-
/**
|
|
122
|
-
* Applies a vendor's recommendations to one line: always refreshes the dropdown's "Recommended"
|
|
123
|
-
* group, but only prefills account/class when the field is still empty. Callers switching
|
|
124
|
-
* vendors clear the previous prefill first, so "empty" includes what the last vendor filled. Anything the user
|
|
125
|
-
* picked wins -- this follows the transaction-categorization helper, which prefills, rather
|
|
126
|
-
* than the detail-page helper, which only suggests.
|
|
127
|
-
*/
|
|
128
|
-
const applyRecommendationsToCreateTransactionLine = (line, recommendations, isAccountingClassesEnabled) => {
|
|
129
|
-
const top = recommendations[0];
|
|
130
|
-
const updated = {
|
|
131
|
-
...line,
|
|
132
|
-
recommendationsWithCOT: (0, exports.toRecommendationsWithCOT)(recommendations),
|
|
133
|
-
};
|
|
134
|
-
if (line.accountQboId == null && top?.account?.qboId != null) {
|
|
135
|
-
updated.accountQboId = top.account.qboId;
|
|
136
|
-
updated.accountName = top.account.accountName;
|
|
137
|
-
updated.isAccountPreFilled = true;
|
|
138
|
-
}
|
|
139
|
-
if (isAccountingClassesEnabled &&
|
|
140
|
-
line.classId == null &&
|
|
141
|
-
top?.class?.classId != null) {
|
|
142
|
-
updated.classId = top.class.classId;
|
|
143
|
-
updated.className = top.class.className;
|
|
144
|
-
updated.isClassPreFilled = true;
|
|
145
|
-
}
|
|
146
|
-
return updated;
|
|
147
|
-
};
|
|
148
|
-
exports.applyRecommendationsToCreateTransactionLine = applyRecommendationsToCreateTransactionLine;
|
|
149
|
-
/**
|
|
150
|
-
* Undoes a prefill when the vendor is cleared. Only the fields the prefill wrote are removed --
|
|
151
|
-
* the per-field flags are what make the user's own choices distinguishable from ours, which is
|
|
152
|
-
* why they are not a single line-level boolean: a hand-picked account alongside a prefilled
|
|
153
|
-
* class is an ordinary state, and clearing must not take the account with it.
|
|
154
|
-
*/
|
|
155
|
-
const clearRecommendationsFromCreateTransactionLine = (line) => {
|
|
156
|
-
const cleared = {
|
|
157
|
-
...line,
|
|
158
|
-
recommendationsWithCOT: undefined,
|
|
159
|
-
};
|
|
160
|
-
if (line.isAccountPreFilled === true) {
|
|
161
|
-
cleared.accountQboId = undefined;
|
|
162
|
-
cleared.accountName = undefined;
|
|
163
|
-
cleared.isAccountPreFilled = undefined;
|
|
164
|
-
}
|
|
165
|
-
if (line.isClassPreFilled === true) {
|
|
166
|
-
cleared.classId = undefined;
|
|
167
|
-
cleared.className = undefined;
|
|
168
|
-
cleared.isClassPreFilled = undefined;
|
|
169
|
-
}
|
|
170
|
-
return cleared;
|
|
171
|
-
};
|
|
172
|
-
exports.clearRecommendationsFromCreateTransactionLine = clearRecommendationsFromCreateTransactionLine;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import { ProjectBasePayload } from '../../../entity/project/projectPayload';
|
|
3
|
-
import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
|
|
4
|
-
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
5
|
-
import { RootState } from '../../../rootStateTypes';
|
|
6
|
-
import { CreateTransactionLocalData } from './createTransactionState';
|
|
7
|
-
/**
|
|
8
|
-
* Wire types for POST /1.0/transactions/manage.
|
|
9
|
-
*
|
|
10
|
-
* Two things here are easy to get wrong and are deliberately explicit:
|
|
11
|
-
*
|
|
12
|
-
* 1. `line_detail_type` is snake_case. The PascalCase strings in the backend are Python
|
|
13
|
-
* constant NAMES; ZENI_LINE_DETAIL_TYPE_TO_QBO_LINE_DETAIL_TYPE_MAP converts them for the
|
|
14
|
-
* body the backend sends on to QuickBooks, never for ours.
|
|
15
|
-
* 2. The reference number uses two different keys depending on the QBO entity. check and
|
|
16
|
-
* expense are Purchases and take `document_number`; everything else takes `document_id`.
|
|
17
|
-
*/
|
|
18
|
-
export interface CreateTransactionAccountPayload {
|
|
19
|
-
qbo_id: ID;
|
|
20
|
-
account_name?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface CreateTransactionLineDetailPayload {
|
|
23
|
-
account?: CreateTransactionAccountPayload;
|
|
24
|
-
class?: Record<string, never> | {
|
|
25
|
-
qbo_id: ID;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* journal_entry only, and it MUST sit inside line_detail. The write validator's docstring
|
|
29
|
-
* warns that a misplaced posting_type is silently dropped and then rejected by QBO.
|
|
30
|
-
*/
|
|
31
|
-
posting_type?: 'credit' | 'debit';
|
|
32
|
-
/** Same shape the transaction update sends on a vendor line. */
|
|
33
|
-
project?: ProjectBasePayload;
|
|
34
|
-
vendor?: {
|
|
35
|
-
qbo_id: ID;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export interface CreateTransactionLinePayload {
|
|
39
|
-
amount: number;
|
|
40
|
-
line_detail: CreateTransactionLineDetailPayload;
|
|
41
|
-
line_detail_type: 'account_based_expense_line_detail' | 'item_based_expense_line_detail' | 'journal_entry_line_detail';
|
|
42
|
-
line_description?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface CreateTransactionRemitToAddressPayload {
|
|
45
|
-
city?: string;
|
|
46
|
-
country?: string;
|
|
47
|
-
line1?: string;
|
|
48
|
-
postal_code?: string;
|
|
49
|
-
state?: string;
|
|
50
|
-
}
|
|
51
|
-
export interface CreateTransactionRequest extends Record<string, unknown> {
|
|
52
|
-
transaction_date: string;
|
|
53
|
-
transaction_type: string;
|
|
54
|
-
/** journal_entry reference number. */
|
|
55
|
-
document_id?: string;
|
|
56
|
-
/** check / credit_card_credit reference number (QBO Purchase). */
|
|
57
|
-
document_number?: string;
|
|
58
|
-
from_account_id?: ID;
|
|
59
|
-
/** credit_card_credit is modelled as a Purchase with Credit: true. */
|
|
60
|
-
is_credit?: boolean;
|
|
61
|
-
lines?: CreateTransactionLinePayload[];
|
|
62
|
-
payment_type?: string;
|
|
63
|
-
print_status?: string;
|
|
64
|
-
qbo_account_id?: ID;
|
|
65
|
-
remit_to_address?: CreateTransactionRemitToAddressPayload;
|
|
66
|
-
to_account_id?: ID;
|
|
67
|
-
total_amount?: number;
|
|
68
|
-
transaction_memo?: string;
|
|
69
|
-
vendor_id?: ID;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* The create endpoint writes to QBO and returns the created entity; Zeni's own mirror is
|
|
73
|
-
* populated by the delta sync that runs afterwards, so this response is the only view of the
|
|
74
|
-
* new transaction the client gets immediately.
|
|
75
|
-
*/
|
|
76
|
-
export interface CreateTransactionPayload {
|
|
77
|
-
transactions: TransactionPayload[];
|
|
78
|
-
}
|
|
79
|
-
export type CreateTransactionResponse = ZeniAPIResponse<CreateTransactionPayload>;
|
|
80
|
-
/**
|
|
81
|
-
* Thrown when a picked id has no QBO id to send. Sending the Zeni id instead would reach QBO as
|
|
82
|
-
* an unknown reference and come back as an opaque error, so the create is stopped here and the
|
|
83
|
-
* epic shows this message instead.
|
|
84
|
-
*/
|
|
85
|
-
export declare class UnresolvedCreateTransactionIdError extends Error {
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Builds the request body for one transaction type. One branch per type rather than a shared
|
|
89
|
-
* body with optional keys, because the types genuinely diverge -- transfer carries no lines at
|
|
90
|
-
* all, and journal_entry carries no header account.
|
|
91
|
-
*
|
|
92
|
-
* Throws UnresolvedCreateTransactionIdError when a picked vendor (header or journal entry line),
|
|
93
|
-
* class or transfer account has no QBO id.
|
|
94
|
-
*/
|
|
95
|
-
export declare const prepareCreateTransactionPayload: (state: RootState, localData: CreateTransactionLocalData) => CreateTransactionRequest;
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareCreateTransactionPayload = exports.UnresolvedCreateTransactionIdError = void 0;
|
|
4
|
-
const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
|
|
5
|
-
const accountSelector_1 = require("../../../entity/account/accountSelector");
|
|
6
|
-
const classSelector_1 = require("../../../entity/class/classSelector");
|
|
7
|
-
const projectPayload_1 = require("../../../entity/project/projectPayload");
|
|
8
|
-
const projectSelector_1 = require("../../../entity/project/projectSelector");
|
|
9
|
-
const vendorSelector_1 = require("../../../entity/vendor/vendorSelector");
|
|
10
|
-
const toRemitToAddressPayload = (address) => {
|
|
11
|
-
if (address == null) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
line1: address.line1,
|
|
16
|
-
city: address.city,
|
|
17
|
-
state: address.state,
|
|
18
|
-
postal_code: address.postalCode,
|
|
19
|
-
country: address.country,
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const toLinePayload = (state, line, transactionType) => {
|
|
23
|
-
const lineDetail = {};
|
|
24
|
-
if (line.accountQboId != null) {
|
|
25
|
-
lineDetail.account = {
|
|
26
|
-
qbo_id: line.accountQboId,
|
|
27
|
-
account_name: line.accountName,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
// An empty object is what the confirmed payloads send when no class is chosen; sending the
|
|
31
|
-
// key with a qbo_id only once one is picked.
|
|
32
|
-
const classQboId = toQboClassId(state, line.classId);
|
|
33
|
-
lineDetail.class = classQboId != null ? { qbo_id: classQboId } : {};
|
|
34
|
-
if (line.projectId != null) {
|
|
35
|
-
lineDetail.project = (0, projectPayload_1.toProjectBasePayload)((0, projectSelector_1.getProjectById)(state.projectState, line.projectId) ?? {
|
|
36
|
-
projectId: line.projectId,
|
|
37
|
-
projectName: '',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (transactionType === 'journal_entry') {
|
|
41
|
-
lineDetail.posting_type = line.postingType;
|
|
42
|
-
const vendorQboId = toQboLineVendorId(state, line.vendorQboId);
|
|
43
|
-
if (vendorQboId != null) {
|
|
44
|
-
lineDetail.vendor = { qbo_id: vendorQboId };
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
// The backend rejects a bool here, so this is always coerced to a number.
|
|
49
|
-
amount: line.amount?.amount ?? 0,
|
|
50
|
-
line_description: line.lineDescription,
|
|
51
|
-
line_detail_type: transactionType === 'journal_entry'
|
|
52
|
-
? 'journal_entry_line_detail'
|
|
53
|
-
: 'account_based_expense_line_detail',
|
|
54
|
-
line_detail: lineDetail,
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Thrown when a picked id has no QBO id to send. Sending the Zeni id instead would reach QBO as
|
|
59
|
-
* an unknown reference and come back as an opaque error, so the create is stopped here and the
|
|
60
|
-
* epic shows this message instead.
|
|
61
|
-
*/
|
|
62
|
-
class UnresolvedCreateTransactionIdError extends Error {
|
|
63
|
-
}
|
|
64
|
-
exports.UnresolvedCreateTransactionIdError = UnresolvedCreateTransactionIdError;
|
|
65
|
-
/**
|
|
66
|
-
* Resolves a transfer account (the Zeni account id from the transfer pools) to its QBO id. The
|
|
67
|
-
* header and line account dropdowns already hold the QBO id, so they are sent as-is.
|
|
68
|
-
*/
|
|
69
|
-
const toQboTransferAccountId = (state, accountId) => {
|
|
70
|
-
if (accountId == null) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
const qboId = (0, accountSelector_1.getAccountBaseForTransferAccounts)(state.accountState, accountId)?.qboId;
|
|
74
|
-
if (qboId == null || qboId === '') {
|
|
75
|
-
throw new UnresolvedCreateTransactionIdError('The selected transfer account could not be found in QuickBooks.');
|
|
76
|
-
}
|
|
77
|
-
return qboId;
|
|
78
|
-
};
|
|
79
|
-
/** Resolves a Zeni class id (`class_<uuid>`) to the QBO id `line_detail.class.qbo_id` expects. */
|
|
80
|
-
const toQboClassId = (state, classId) => {
|
|
81
|
-
if (classId == null) {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
const qboId = (0, classSelector_1.getClassById)(state.classState, {
|
|
85
|
-
classId,
|
|
86
|
-
reportId: 'class_list',
|
|
87
|
-
})?.qboId;
|
|
88
|
-
if (qboId == null || qboId === '') {
|
|
89
|
-
throw new UnresolvedCreateTransactionIdError('The selected class could not be found in QuickBooks.');
|
|
90
|
-
}
|
|
91
|
-
return qboId;
|
|
92
|
-
};
|
|
93
|
-
/** A vendor not yet synced to QBO carries `qboId === name`, which QBO would reject. */
|
|
94
|
-
const toSyncedVendorQboId = (vendor) => {
|
|
95
|
-
if (vendor == null || vendor.qboId === '' || vendor.qboId === vendor.name) {
|
|
96
|
-
throw new UnresolvedCreateTransactionIdError('The selected vendor is not synced to QuickBooks yet.');
|
|
97
|
-
}
|
|
98
|
-
return vendor.qboId;
|
|
99
|
-
};
|
|
100
|
-
/** Resolves a Zeni vendor id to its QBO id -- `vendor_id` on the wire is a QBO id. */
|
|
101
|
-
const toQboVendorId = (state, vendorId) => vendorId == null
|
|
102
|
-
? undefined
|
|
103
|
-
: toSyncedVendorQboId((0, vendorSelector_1.getVendorByVendorId)(state.vendorState, vendorId));
|
|
104
|
-
/** A journal entry line holds the QBO id already, so it is only checked against the store. */
|
|
105
|
-
const toQboLineVendorId = (state, vendorQboId) => vendorQboId == null
|
|
106
|
-
? undefined
|
|
107
|
-
: toSyncedVendorQboId((0, vendorSelector_1.getVendorByQboId)(state.vendorState, vendorQboId));
|
|
108
|
-
/**
|
|
109
|
-
* Builds the request body for one transaction type. One branch per type rather than a shared
|
|
110
|
-
* body with optional keys, because the types genuinely diverge -- transfer carries no lines at
|
|
111
|
-
* all, and journal_entry carries no header account.
|
|
112
|
-
*
|
|
113
|
-
* Throws UnresolvedCreateTransactionIdError when a picked vendor (header or journal entry line),
|
|
114
|
-
* class or transfer account has no QBO id.
|
|
115
|
-
*/
|
|
116
|
-
const prepareCreateTransactionPayload = (state, localData) => {
|
|
117
|
-
const { transactionType } = localData;
|
|
118
|
-
const base = {
|
|
119
|
-
transaction_type: transactionType,
|
|
120
|
-
transaction_date: localData.transactionDate?.format(timePeriod_1.DEFAULT_DATE_FORMAT) ?? '',
|
|
121
|
-
transaction_memo: localData.transactionMemo,
|
|
122
|
-
};
|
|
123
|
-
if (transactionType === 'transfer') {
|
|
124
|
-
return {
|
|
125
|
-
...base,
|
|
126
|
-
from_account_id: toQboTransferAccountId(state, localData.fromAccountId),
|
|
127
|
-
to_account_id: toQboTransferAccountId(state, localData.toAccountId),
|
|
128
|
-
total_amount: localData.totalAmount?.amount ?? 0,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const lines = localData.lines.map((line) => toLinePayload(state, line, transactionType));
|
|
132
|
-
if (transactionType === 'journal_entry') {
|
|
133
|
-
return {
|
|
134
|
-
...base,
|
|
135
|
-
document_id: localData.documentId,
|
|
136
|
-
lines,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
const purchaseBase = {
|
|
140
|
-
...base,
|
|
141
|
-
payment_type: localData.paymentType,
|
|
142
|
-
qbo_account_id: localData.qboAccountId,
|
|
143
|
-
vendor_id: toQboVendorId(state, localData.vendorId),
|
|
144
|
-
lines,
|
|
145
|
-
};
|
|
146
|
-
if (transactionType === 'check') {
|
|
147
|
-
return {
|
|
148
|
-
...purchaseBase,
|
|
149
|
-
document_number: localData.documentNumber,
|
|
150
|
-
print_status: localData.printStatus,
|
|
151
|
-
remit_to_address: toRemitToAddressPayload(localData.remitToAddress),
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
if (transactionType === 'credit_card_credit') {
|
|
155
|
-
// credit_card_credit is not in the backend's SUPPORTED_TRANSACTION_WRITE_TYPES. QBO models
|
|
156
|
-
// it as a Purchase with Credit: true and qbo_purchase.py already honours is_credit for
|
|
157
|
-
// card payment types, so this sends `expense` + is_credit rather than a type the validator
|
|
158
|
-
// rejects outright. Confirm with backend before enabling the menu item. The seed sets
|
|
159
|
-
// payment_type to credit_card, since qbo_purchase.py raises on is_credit without a card type.
|
|
160
|
-
return {
|
|
161
|
-
...purchaseBase,
|
|
162
|
-
transaction_type: 'expense',
|
|
163
|
-
is_credit: true,
|
|
164
|
-
document_number: localData.documentNumber,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return purchaseBase;
|
|
168
|
-
};
|
|
169
|
-
exports.prepareCreateTransactionPayload = prepareCreateTransactionPayload;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
|
|
2
|
-
import { NestedClassHierarchyForReport } from '../../../commonStateTypes/classesView/nestedClassID';
|
|
3
|
-
import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common';
|
|
4
|
-
import { Recommendation } from '../../../commonStateTypes/recommendationBase';
|
|
5
|
-
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
6
|
-
import { AccountBase } from '../../../entity/account/accountState';
|
|
7
|
-
import { TransactionID } from '../../../entity/transaction/stateTypes/transactionID';
|
|
8
|
-
import { Vendor } from '../../../entity/vendor/vendorState';
|
|
9
|
-
import { RootState } from '../../../rootStateTypes';
|
|
10
|
-
import { CreatableTransactionType, CreateTransactionLocalData } from './createTransactionState';
|
|
11
|
-
export interface CreateTransactionView extends SelectorView {
|
|
12
|
-
/**
|
|
13
|
-
* COA and class trees for the header account and the line dropdowns. The hierarchies rather
|
|
14
|
-
* than flat lists, because the create page builds its grouped "Recommended" / "All" options
|
|
15
|
-
* with the same helpers the detail page uses.
|
|
16
|
-
*/
|
|
17
|
-
accountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
|
|
18
|
-
classListNestedAccountHierarchy: NestedClassHierarchyForReport[];
|
|
19
|
-
createStatus: FetchStateAndError;
|
|
20
|
-
localData: CreateTransactionLocalData;
|
|
21
|
-
transactionType: CreatableTransactionType;
|
|
22
|
-
/** Populated for transfer only; the COA would offer ineligible accounts. */
|
|
23
|
-
transferAccountsList: AccountBase[];
|
|
24
|
-
vendorList: Vendor[];
|
|
25
|
-
createdTransactionId?: TransactionID;
|
|
26
|
-
}
|
|
27
|
-
export declare const getCreateTransactionLocalData: (state: RootState, transactionType: CreatableTransactionType) => CreateTransactionLocalData;
|
|
28
|
-
export declare const getCreateTransactionStatus: (state: RootState) => FetchStateAndError;
|
|
29
|
-
/**
|
|
30
|
-
* The vendor recommendations backing the category/class dropdowns on the create page.
|
|
31
|
-
*
|
|
32
|
-
* No new state field is needed for this: getRecommendationsForEntity already returns
|
|
33
|
-
* fetchState alongside recommendations, so composing it here is enough for the page to show a
|
|
34
|
-
* line skeleton and hold Save while a fetch is in flight.
|
|
35
|
-
*/
|
|
36
|
-
export declare const getCreateTransactionVendorRecommendations: (state: RootState, vendorQboId?: string) => {
|
|
37
|
-
fetchState: FetchState;
|
|
38
|
-
recommendations?: Recommendation[];
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Memoized: app-ui reads this straight from useSelector, and the vendor list and hierarchies are
|
|
42
|
-
* rebuilt on every call, so an unmemoized version re-renders the page on every store action.
|
|
43
|
-
*/
|
|
44
|
-
export declare const getCreateTransactionView: (state: RootState, transactionType: CreatableTransactionType) => CreateTransactionView;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCreateTransactionView = exports.getCreateTransactionVendorRecommendations = exports.getCreateTransactionStatus = exports.getCreateTransactionLocalData = void 0;
|
|
4
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
5
|
-
const accountListSelector_1 = require("../../accountList/accountListSelector");
|
|
6
|
-
const classListSelector_1 = require("../../classList/classListSelector");
|
|
7
|
-
const createTransferEntrySelector_1 = require("../../createTransferEntry/createTransferEntrySelector");
|
|
8
|
-
const recommendationSelector_1 = require("../../recommendation/recommendationSelector");
|
|
9
|
-
const getCreateTransactionLocalData = (state, transactionType) => state.transactionDetailState.createTransactionsState.newTransactionState[transactionType];
|
|
10
|
-
exports.getCreateTransactionLocalData = getCreateTransactionLocalData;
|
|
11
|
-
const getCreateTransactionStatus = (state) => state.transactionDetailState.createTransactionsState.createStatus;
|
|
12
|
-
exports.getCreateTransactionStatus = getCreateTransactionStatus;
|
|
13
|
-
/**
|
|
14
|
-
* The vendor recommendations backing the category/class dropdowns on the create page.
|
|
15
|
-
*
|
|
16
|
-
* No new state field is needed for this: getRecommendationsForEntity already returns
|
|
17
|
-
* fetchState alongside recommendations, so composing it here is enough for the page to show a
|
|
18
|
-
* line skeleton and hold Save while a fetch is in flight.
|
|
19
|
-
*/
|
|
20
|
-
const getCreateTransactionVendorRecommendations = (state, vendorQboId) => {
|
|
21
|
-
if (vendorQboId == null || vendorQboId === '') {
|
|
22
|
-
return { fetchState: 'Not-Started' };
|
|
23
|
-
}
|
|
24
|
-
const view = (0, recommendationSelector_1.getRecommendationsForEntity)(state, vendorQboId, 'vendor');
|
|
25
|
-
return {
|
|
26
|
-
fetchState: view.fetchState,
|
|
27
|
-
recommendations: view.recommendations,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
exports.getCreateTransactionVendorRecommendations = getCreateTransactionVendorRecommendations;
|
|
31
|
-
/**
|
|
32
|
-
* Memoized: app-ui reads this straight from useSelector, and the vendor list and hierarchies are
|
|
33
|
-
* rebuilt on every call, so an unmemoized version re-renders the page on every store action.
|
|
34
|
-
*/
|
|
35
|
-
exports.getCreateTransactionView = (0, toolkit_1.createSelector)([
|
|
36
|
-
(state) => state.transactionDetailState.createTransactionsState,
|
|
37
|
-
(state) => state.vendorState.vendorByID,
|
|
38
|
-
(state) => state.accountListState,
|
|
39
|
-
(state) => state.classListState,
|
|
40
|
-
(state) => (0, createTransferEntrySelector_1.getResolvedTransferAccounts)(state).transferAccountsList,
|
|
41
|
-
(_state, transactionType) => transactionType,
|
|
42
|
-
], (createTransactionsState, vendorByID, accountListState, classListState, transferAccountsList, transactionType) => ({
|
|
43
|
-
transactionType,
|
|
44
|
-
localData: createTransactionsState.newTransactionState[transactionType],
|
|
45
|
-
createStatus: createTransactionsState.createStatus,
|
|
46
|
-
createdTransactionId: createTransactionsState.createdTransactionId,
|
|
47
|
-
vendorList: Object.values(vendorByID),
|
|
48
|
-
accountListNestedAccountHierarchy: (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'accountList'),
|
|
49
|
-
classListNestedAccountHierarchy: (0, classListSelector_1.getNestedClassListHierarchy)(classListState),
|
|
50
|
-
transferAccountsList: transactionType === 'transfer' ? transferAccountsList : [],
|
|
51
|
-
fetchState: createTransactionsState.createStatus.fetchState,
|
|
52
|
-
error: createTransactionsState.createStatus.error,
|
|
53
|
-
}));
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
|
-
import { ID } from '../../../commonStateTypes/common';
|
|
3
|
-
import { RecommendationWithCOT } from '../../../commonStateTypes/recommendationBase';
|
|
4
|
-
import { PaymentType } from '../../../entity/transaction/stateTypes/paymentType';
|
|
5
|
-
import { PrintStatus } from '../../../entity/transaction/stateTypes/printStatus';
|
|
6
|
-
import { TransactionCategory, TransactionType } from '../../../entity/transaction/stateTypes/transactionType';
|
|
7
|
-
import { ZeniDate } from '../../../zeniDayJS';
|
|
8
|
-
/**
|
|
9
|
-
* The transaction types the Create Transaction flow can originate. A narrow subset of
|
|
10
|
-
* TransactionType -- everything else is read-only and arrives via sync.
|
|
11
|
-
*/
|
|
12
|
-
export declare const ALL_CREATABLE_TRANSACTION_TYPES: readonly ["expense", "check", "credit_card_credit", "transfer", "journal_entry"];
|
|
13
|
-
export type CreatableTransactionType = (typeof ALL_CREATABLE_TRANSACTION_TYPES)[number];
|
|
14
|
-
/**
|
|
15
|
-
* The wire shape the create endpoint expects for a check's remit-to address. Deliberately not
|
|
16
|
-
* the CES AddressPayload, which carries `street: string[]` plus address_id/create_time/
|
|
17
|
-
* update_time that the create endpoint does not accept.
|
|
18
|
-
*/
|
|
19
|
-
export interface RemitToAddress {
|
|
20
|
-
city?: string;
|
|
21
|
-
country?: string;
|
|
22
|
-
line1?: string;
|
|
23
|
-
postalCode?: string;
|
|
24
|
-
state?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface CreateTransactionLineLocalData {
|
|
27
|
-
/** Client-side row key only -- never sent. */
|
|
28
|
-
id: string;
|
|
29
|
-
accountName?: string;
|
|
30
|
-
accountQboId?: ID;
|
|
31
|
-
amount?: Amount;
|
|
32
|
-
classId?: ID;
|
|
33
|
-
className?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Tracked per field, not per line. A line can have a hand-picked account and a prefilled
|
|
36
|
-
* class at the same time, and clearing the vendor must undo only the latter.
|
|
37
|
-
*/
|
|
38
|
-
isAccountPreFilled?: boolean;
|
|
39
|
-
isClassPreFilled?: boolean;
|
|
40
|
-
lineDescription?: string;
|
|
41
|
-
/** journal_entry only. */
|
|
42
|
-
postingType?: TransactionCategory;
|
|
43
|
-
projectId?: ID;
|
|
44
|
-
/**
|
|
45
|
-
* Backs the "Recommended" group in the category/class dropdowns. Carries the COT shape the
|
|
46
|
-
* line-table row already expects, with empty cot/reasoning -- chain-of-thought needs an
|
|
47
|
-
* existing transaction, which a create does not have.
|
|
48
|
-
*/
|
|
49
|
-
recommendationsWithCOT?: RecommendationWithCOT[];
|
|
50
|
-
/** journal_entry only -- the per-line name. */
|
|
51
|
-
vendorQboId?: ID;
|
|
52
|
-
}
|
|
53
|
-
export interface CreateTransactionLocalData {
|
|
54
|
-
/** Empty for transfer, which has no lines at all. */
|
|
55
|
-
lines: CreateTransactionLineLocalData[];
|
|
56
|
-
transactionType: CreatableTransactionType;
|
|
57
|
-
/** journal_entry reference number. */
|
|
58
|
-
documentId?: string;
|
|
59
|
-
/** check / credit_card_credit reference number. */
|
|
60
|
-
documentNumber?: string;
|
|
61
|
-
/** transfer */
|
|
62
|
-
fromAccountId?: ID;
|
|
63
|
-
paymentType?: PaymentType;
|
|
64
|
-
/** check only. */
|
|
65
|
-
printStatus?: PrintStatus;
|
|
66
|
-
qboAccountId?: ID;
|
|
67
|
-
/** check only. */
|
|
68
|
-
remitToAddress?: RemitToAddress;
|
|
69
|
-
toAccountId?: ID;
|
|
70
|
-
/** transfer only -- every other type derives its total from the lines. */
|
|
71
|
-
totalAmount?: Amount;
|
|
72
|
-
transactionDate?: ZeniDate;
|
|
73
|
-
transactionMemo?: string;
|
|
74
|
-
vendorId?: ID;
|
|
75
|
-
}
|
|
76
|
-
export type CreateTransactionLocalDataByType = Record<CreatableTransactionType, CreateTransactionLocalData>;
|
|
77
|
-
/**
|
|
78
|
-
* Type-level guarantee that CreatableTransactionType stays a subset of TransactionType. If a
|
|
79
|
-
* value is ever added here that the entity layer does not know about, this line fails to
|
|
80
|
-
* compile rather than failing at the payload boundary.
|
|
81
|
-
*/
|
|
82
|
-
export type CreatableTransactionTypeIsTransactionType = CreatableTransactionType extends TransactionType ? true : never;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ALL_CREATABLE_TRANSACTION_TYPES = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The transaction types the Create Transaction flow can originate. A narrow subset of
|
|
6
|
-
* TransactionType -- everything else is read-only and arrives via sync.
|
|
7
|
-
*/
|
|
8
|
-
exports.ALL_CREATABLE_TRANSACTION_TYPES = [
|
|
9
|
-
'expense',
|
|
10
|
-
'check',
|
|
11
|
-
'credit_card_credit',
|
|
12
|
-
'transfer',
|
|
13
|
-
'journal_entry',
|
|
14
|
-
];
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { createTransactionAttachmentUploadFailure } from '../../transactionDetailReducer';
|
|
5
|
-
export type ActionType = ReturnType<typeof createTransactionAttachmentUploadFailure> | ReturnType<typeof openSnackbar>;
|
|
6
|
-
/**
|
|
7
|
-
* Attachments upload from the page after the create succeeds, so a failure is reported back here
|
|
8
|
-
* rather than by createTransactionEpic.
|
|
9
|
-
*/
|
|
10
|
-
export declare const createTransactionAttachmentUploadFailureEpic: (actions$: ActionsObservable<ActionType>) => Observable<ActionType>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTransactionAttachmentUploadFailureEpic = void 0;
|
|
4
|
-
const operators_1 = require("rxjs/operators");
|
|
5
|
-
const snackbarReducer_1 = require("../../../../entity/snackbar/snackbarReducer");
|
|
6
|
-
const transactionDetailReducer_1 = require("../../transactionDetailReducer");
|
|
7
|
-
/**
|
|
8
|
-
* Attachments upload from the page after the create succeeds, so a failure is reported back here
|
|
9
|
-
* rather than by createTransactionEpic.
|
|
10
|
-
*/
|
|
11
|
-
const createTransactionAttachmentUploadFailureEpic = (actions$) => actions$.pipe((0, operators_1.filter)(transactionDetailReducer_1.createTransactionAttachmentUploadFailure.match), (0, operators_1.filter)((action) => action.payload.failedAttachmentFileNames.length > 0), (0, operators_1.map)((action) => (0, snackbarReducer_1.openSnackbar)({
|
|
12
|
-
messageSection: 'missing_receipts_attachment',
|
|
13
|
-
messageText: 'failed',
|
|
14
|
-
type: 'error',
|
|
15
|
-
showStatusIcon: true,
|
|
16
|
-
variables: [
|
|
17
|
-
{
|
|
18
|
-
variableName: '__message__',
|
|
19
|
-
variableValue: ` - ${action.payload.failedAttachmentFileNames.join(', ')},`,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
})));
|
|
23
|
-
exports.createTransactionAttachmentUploadFailureEpic = createTransactionAttachmentUploadFailureEpic;
|