@zeniai/client-epic-state 5.2.10-betaAK2 → 5.2.10-betaAK4
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/invoicingCommonPayload.d.ts +7 -18
- package/lib/entity/invoicing/invoicingCommonPayload.js +36 -86
- package/lib/esm/entity/invoicing/invoicingCommonPayload.js +35 -84
- package/lib/esm/index.js +0 -1
- package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +7 -1
- package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +8 -5
- package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +2 -7
- package/lib/index.d.ts +0 -2
- package/lib/index.js +7 -10
- package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +7 -1
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +8 -3
- package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +7 -4
- package/lib/view/invoicing/settingsView/settingsViewSelector.js +1 -6
- package/package.json +1 -1
|
@@ -130,28 +130,17 @@ export declare const firstSelectableInvoicingId: (candidates: readonly (string |
|
|
|
130
130
|
* Read one account-mapping dropdown value by its config `code` (the codes in
|
|
131
131
|
* `qbo_account_mapping_kind_options` match the `account_mappings` field names).
|
|
132
132
|
*/
|
|
133
|
-
export declare function getInvoicingQboAccountMappingId(accountMappings: InvoicingQboAccountMappingsPayload | undefined, code:
|
|
134
|
-
/**
|
|
135
|
-
* Return a copy of the account mappings with the dropdown slot named by
|
|
136
|
-
* `code` set to `accountId`. Unknown codes leave the mappings unchanged.
|
|
137
|
-
*/
|
|
138
|
-
/** Every account-mapping slot the page can set, in the order it renders them. */
|
|
139
|
-
export declare const INVOICING_QBO_ACCOUNT_MAPPING_CODES: readonly ["deposit_account_id", "default_income_account_id", "discounts_account_id", "rounding_account_id", "write_off_account_id"];
|
|
140
|
-
export type InvoicingQboAccountMappingCode = (typeof INVOICING_QBO_ACCOUNT_MAPPING_CODES)[number];
|
|
141
|
-
/**
|
|
142
|
-
* Narrows a mapping code that arrived from the config API. Anything the client
|
|
143
|
-
* has no slot for returns undefined rather than being cast through: a code we
|
|
144
|
-
* cannot place is a mapping we cannot read or write.
|
|
145
|
-
*/
|
|
146
|
-
export declare const toInvoicingQboAccountMappingCode: (code: string) => InvoicingQboAccountMappingCode | undefined;
|
|
133
|
+
export declare function getInvoicingQboAccountMappingId(accountMappings: InvoicingQboAccountMappingsPayload | undefined, code: string): string | undefined;
|
|
147
134
|
/**
|
|
148
135
|
* Expand each mapping from the id the picker submitted to the whole account, the
|
|
149
|
-
* shape the service stores
|
|
150
|
-
*
|
|
151
|
-
*
|
|
136
|
+
* shape the service stores: `deposit_account_id: '35'` becomes
|
|
137
|
+
* `deposit_account: {qbo_id: '35', account_id, account_name, …}`. Written at the
|
|
138
|
+
* request boundary rather than in the page's draft, so the UI keeps working in
|
|
139
|
+
* ids. An id that resolves to no account keeps its bare form rather than being
|
|
140
|
+
* dropped.
|
|
152
141
|
*/
|
|
153
142
|
export declare const withInvoicingQboMappedAccounts: (accountMappings: InvoicingQboAccountMappingsPayload | undefined, accountByQboId: (qboId: string) => AccountBase | undefined) => InvoicingQboAccountMappingsPayload | undefined;
|
|
154
|
-
export declare function withInvoicingQboAccountMappingId(accountMappings: InvoicingQboAccountMappingsPayload | undefined, code:
|
|
143
|
+
export declare function withInvoicingQboAccountMappingId(accountMappings: InvoicingQboAccountMappingsPayload | undefined, code: string, accountId: string): InvoicingQboAccountMappingsPayload;
|
|
155
144
|
export interface InvoicingQboSettingsPayload {
|
|
156
145
|
account_mappings?: InvoicingQboAccountMappingsPayload | null;
|
|
157
146
|
auto_create_items?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ALL_INVOICING_FIELD_HELP_GROUPS = exports.withInvoicingQboMappedAccounts = exports.
|
|
3
|
+
exports.ALL_INVOICING_FIELD_HELP_GROUPS = exports.withInvoicingQboMappedAccounts = exports.firstSelectableInvoicingId = exports.INVOICING_QBO_CUSTOMER_MATCHING_MODES = exports.INVOICING_DISCOUNT_LIFECYCLE_ACTIONS = exports.INVOICING_CATALOG_PRODUCT_LIFECYCLE_ACTIONS = exports.INVOICING_CATALOG_ITEM_LIFECYCLE_ACTIONS = exports.INVOICING_SUBSCRIPTION_LIFECYCLE_ACTIONS = exports.INVOICING_DUNNING_ACTIONS = void 0;
|
|
4
4
|
exports.toInvoicingDunningAction = toInvoicingDunningAction;
|
|
5
5
|
exports.toInvoicingSubscriptionLifecycleAction = toInvoicingSubscriptionLifecycleAction;
|
|
6
6
|
exports.toInvoicingSubscriptionLifecycleActionOption = toInvoicingSubscriptionLifecycleActionOption;
|
|
@@ -176,117 +176,67 @@ function readInvoicingQboMappedAccountId(mappedAccount, legacyAccountId) {
|
|
|
176
176
|
legacyAccountId,
|
|
177
177
|
]);
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* The object key holding a mapped account, derived from its `*_account_id` code:
|
|
181
|
+
* `deposit_account_id` arrives either as `deposit_account_id` or as a
|
|
182
|
+
* `deposit_account` record. Derived rather than listed — the set of slots is the
|
|
183
|
+
* config API's to grow, and a hardcoded list silently ignores any code it has
|
|
184
|
+
* not heard of, which shows up as a mapping that will not save.
|
|
185
|
+
*/
|
|
186
|
+
const mappedAccountKeyForCode = (code) => code.replace(/_id$/, '');
|
|
187
|
+
/** Every mapping code a payload carries, in either shape. */
|
|
188
|
+
const mappingCodesIn = (accountMappings) => [
|
|
189
|
+
...new Set(Object.keys(accountMappings).map((key) => key.endsWith('_id') ? key : `${key}_id`)),
|
|
190
|
+
];
|
|
179
191
|
/**
|
|
180
192
|
* Read one account-mapping dropdown value by its config `code` (the codes in
|
|
181
193
|
* `qbo_account_mapping_kind_options` match the `account_mappings` field names).
|
|
182
194
|
*/
|
|
183
195
|
function getInvoicingQboAccountMappingId(accountMappings, code) {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
case 'default_income_account_id':
|
|
188
|
-
return readInvoicingQboMappedAccountId(accountMappings?.default_income_account, accountMappings?.default_income_account_id);
|
|
189
|
-
case 'discounts_account_id':
|
|
190
|
-
return readInvoicingQboMappedAccountId(accountMappings?.discounts_account, accountMappings?.discounts_account_id);
|
|
191
|
-
case 'rounding_account_id':
|
|
192
|
-
return readInvoicingQboMappedAccountId(accountMappings?.rounding_account, accountMappings?.rounding_account_id);
|
|
193
|
-
case 'write_off_account_id':
|
|
194
|
-
return readInvoicingQboMappedAccountId(accountMappings?.write_off_account, accountMappings?.write_off_account_id);
|
|
195
|
-
default:
|
|
196
|
-
return undefined;
|
|
197
|
-
}
|
|
196
|
+
const slots = accountMappings;
|
|
197
|
+
const legacyId = slots?.[code];
|
|
198
|
+
return readInvoicingQboMappedAccountId(slots?.[mappedAccountKeyForCode(code)], typeof legacyId === 'string' ? legacyId : undefined);
|
|
198
199
|
}
|
|
199
|
-
/**
|
|
200
|
-
* Return a copy of the account mappings with the dropdown slot named by
|
|
201
|
-
* `code` set to `accountId`. Unknown codes leave the mappings unchanged.
|
|
202
|
-
*/
|
|
203
|
-
/** Every account-mapping slot the page can set, in the order it renders them. */
|
|
204
|
-
exports.INVOICING_QBO_ACCOUNT_MAPPING_CODES = [
|
|
205
|
-
'deposit_account_id',
|
|
206
|
-
'default_income_account_id',
|
|
207
|
-
'discounts_account_id',
|
|
208
|
-
'rounding_account_id',
|
|
209
|
-
'write_off_account_id',
|
|
210
|
-
];
|
|
211
|
-
/**
|
|
212
|
-
* Narrows a mapping code that arrived from the config API. Anything the client
|
|
213
|
-
* has no slot for returns undefined rather than being cast through: a code we
|
|
214
|
-
* cannot place is a mapping we cannot read or write.
|
|
215
|
-
*/
|
|
216
|
-
const toInvoicingQboAccountMappingCode = (code) => exports.INVOICING_QBO_ACCOUNT_MAPPING_CODES.find((knownCode) => knownCode === code);
|
|
217
|
-
exports.toInvoicingQboAccountMappingCode = toInvoicingQboAccountMappingCode;
|
|
218
|
-
/** The object key holding the mapped account for each `*_account_id` code. */
|
|
219
|
-
const INVOICING_QBO_MAPPED_ACCOUNT_KEY = {
|
|
220
|
-
default_income_account_id: 'default_income_account',
|
|
221
|
-
deposit_account_id: 'deposit_account',
|
|
222
|
-
discounts_account_id: 'discounts_account',
|
|
223
|
-
rounding_account_id: 'rounding_account',
|
|
224
|
-
write_off_account_id: 'write_off_account',
|
|
225
|
-
};
|
|
226
200
|
/**
|
|
227
201
|
* Expand each mapping from the id the picker submitted to the whole account, the
|
|
228
|
-
* shape the service stores
|
|
229
|
-
*
|
|
230
|
-
*
|
|
202
|
+
* shape the service stores: `deposit_account_id: '35'` becomes
|
|
203
|
+
* `deposit_account: {qbo_id: '35', account_id, account_name, …}`. Written at the
|
|
204
|
+
* request boundary rather than in the page's draft, so the UI keeps working in
|
|
205
|
+
* ids. An id that resolves to no account keeps its bare form rather than being
|
|
206
|
+
* dropped.
|
|
231
207
|
*/
|
|
232
208
|
const withInvoicingQboMappedAccounts = (accountMappings, accountByQboId) => {
|
|
233
209
|
if (accountMappings == null) {
|
|
234
210
|
return undefined;
|
|
235
211
|
}
|
|
236
212
|
const expanded = { ...accountMappings };
|
|
237
|
-
|
|
238
|
-
const objectKey =
|
|
213
|
+
mappingCodesIn(accountMappings).forEach((code) => {
|
|
214
|
+
const objectKey = mappedAccountKeyForCode(code);
|
|
239
215
|
const accountId = getInvoicingQboAccountMappingId(accountMappings, code);
|
|
240
216
|
if (accountId == null) {
|
|
241
217
|
return;
|
|
242
218
|
}
|
|
243
219
|
const account = accountByQboId(accountId);
|
|
244
|
-
|
|
245
|
-
|
|
220
|
+
if (account == null) {
|
|
221
|
+
// Unresolved: leave the id as it stands rather than dropping the mapping.
|
|
222
|
+
// Sending less than we were given would unset a live configuration.
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
expanded[objectKey] = (0, accountPayload_1.toAccountPayload)(account);
|
|
246
226
|
expanded[code] = undefined;
|
|
247
227
|
});
|
|
248
228
|
return expanded;
|
|
249
229
|
};
|
|
250
230
|
exports.withInvoicingQboMappedAccounts = withInvoicingQboMappedAccounts;
|
|
251
231
|
function withInvoicingQboAccountMappingId(accountMappings, code, accountId) {
|
|
252
|
-
// Both slots are written together
|
|
253
|
-
//
|
|
232
|
+
// Both slots are written together: setting only the bare id would leave the
|
|
233
|
+
// record shape behind, and the reader prefers it — so the selection just made
|
|
254
234
|
// would read back as whatever was mapped before.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
deposit_account: undefined,
|
|
261
|
-
deposit_account_id: accountId,
|
|
262
|
-
};
|
|
263
|
-
case 'default_income_account_id':
|
|
264
|
-
return {
|
|
265
|
-
...base,
|
|
266
|
-
default_income_account: undefined,
|
|
267
|
-
default_income_account_id: accountId,
|
|
268
|
-
};
|
|
269
|
-
case 'discounts_account_id':
|
|
270
|
-
return {
|
|
271
|
-
...base,
|
|
272
|
-
discounts_account: undefined,
|
|
273
|
-
discounts_account_id: accountId,
|
|
274
|
-
};
|
|
275
|
-
case 'rounding_account_id':
|
|
276
|
-
return {
|
|
277
|
-
...base,
|
|
278
|
-
rounding_account: undefined,
|
|
279
|
-
rounding_account_id: accountId,
|
|
280
|
-
};
|
|
281
|
-
case 'write_off_account_id':
|
|
282
|
-
return {
|
|
283
|
-
...base,
|
|
284
|
-
write_off_account: undefined,
|
|
285
|
-
write_off_account_id: accountId,
|
|
286
|
-
};
|
|
287
|
-
default:
|
|
288
|
-
return base;
|
|
289
|
-
}
|
|
235
|
+
return {
|
|
236
|
+
...(accountMappings ?? {}),
|
|
237
|
+
[mappedAccountKeyForCode(code)]: undefined,
|
|
238
|
+
[code]: accountId,
|
|
239
|
+
};
|
|
290
240
|
}
|
|
291
241
|
function toInvoicingQboAccountMappingKindOption(option) {
|
|
292
242
|
return {
|
|
@@ -150,115 +150,66 @@ function readInvoicingQboMappedAccountId(mappedAccount, legacyAccountId) {
|
|
|
150
150
|
legacyAccountId,
|
|
151
151
|
]);
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* The object key holding a mapped account, derived from its `*_account_id` code:
|
|
155
|
+
* `deposit_account_id` arrives either as `deposit_account_id` or as a
|
|
156
|
+
* `deposit_account` record. Derived rather than listed — the set of slots is the
|
|
157
|
+
* config API's to grow, and a hardcoded list silently ignores any code it has
|
|
158
|
+
* not heard of, which shows up as a mapping that will not save.
|
|
159
|
+
*/
|
|
160
|
+
const mappedAccountKeyForCode = (code) => code.replace(/_id$/, '');
|
|
161
|
+
/** Every mapping code a payload carries, in either shape. */
|
|
162
|
+
const mappingCodesIn = (accountMappings) => [
|
|
163
|
+
...new Set(Object.keys(accountMappings).map((key) => key.endsWith('_id') ? key : `${key}_id`)),
|
|
164
|
+
];
|
|
153
165
|
/**
|
|
154
166
|
* Read one account-mapping dropdown value by its config `code` (the codes in
|
|
155
167
|
* `qbo_account_mapping_kind_options` match the `account_mappings` field names).
|
|
156
168
|
*/
|
|
157
169
|
export function getInvoicingQboAccountMappingId(accountMappings, code) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
case 'default_income_account_id':
|
|
162
|
-
return readInvoicingQboMappedAccountId(accountMappings?.default_income_account, accountMappings?.default_income_account_id);
|
|
163
|
-
case 'discounts_account_id':
|
|
164
|
-
return readInvoicingQboMappedAccountId(accountMappings?.discounts_account, accountMappings?.discounts_account_id);
|
|
165
|
-
case 'rounding_account_id':
|
|
166
|
-
return readInvoicingQboMappedAccountId(accountMappings?.rounding_account, accountMappings?.rounding_account_id);
|
|
167
|
-
case 'write_off_account_id':
|
|
168
|
-
return readInvoicingQboMappedAccountId(accountMappings?.write_off_account, accountMappings?.write_off_account_id);
|
|
169
|
-
default:
|
|
170
|
-
return undefined;
|
|
171
|
-
}
|
|
170
|
+
const slots = accountMappings;
|
|
171
|
+
const legacyId = slots?.[code];
|
|
172
|
+
return readInvoicingQboMappedAccountId(slots?.[mappedAccountKeyForCode(code)], typeof legacyId === 'string' ? legacyId : undefined);
|
|
172
173
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Return a copy of the account mappings with the dropdown slot named by
|
|
175
|
-
* `code` set to `accountId`. Unknown codes leave the mappings unchanged.
|
|
176
|
-
*/
|
|
177
|
-
/** Every account-mapping slot the page can set, in the order it renders them. */
|
|
178
|
-
export const INVOICING_QBO_ACCOUNT_MAPPING_CODES = [
|
|
179
|
-
'deposit_account_id',
|
|
180
|
-
'default_income_account_id',
|
|
181
|
-
'discounts_account_id',
|
|
182
|
-
'rounding_account_id',
|
|
183
|
-
'write_off_account_id',
|
|
184
|
-
];
|
|
185
|
-
/**
|
|
186
|
-
* Narrows a mapping code that arrived from the config API. Anything the client
|
|
187
|
-
* has no slot for returns undefined rather than being cast through: a code we
|
|
188
|
-
* cannot place is a mapping we cannot read or write.
|
|
189
|
-
*/
|
|
190
|
-
export const toInvoicingQboAccountMappingCode = (code) => INVOICING_QBO_ACCOUNT_MAPPING_CODES.find((knownCode) => knownCode === code);
|
|
191
|
-
/** The object key holding the mapped account for each `*_account_id` code. */
|
|
192
|
-
const INVOICING_QBO_MAPPED_ACCOUNT_KEY = {
|
|
193
|
-
default_income_account_id: 'default_income_account',
|
|
194
|
-
deposit_account_id: 'deposit_account',
|
|
195
|
-
discounts_account_id: 'discounts_account',
|
|
196
|
-
rounding_account_id: 'rounding_account',
|
|
197
|
-
write_off_account_id: 'write_off_account',
|
|
198
|
-
};
|
|
199
174
|
/**
|
|
200
175
|
* Expand each mapping from the id the picker submitted to the whole account, the
|
|
201
|
-
* shape the service stores
|
|
202
|
-
*
|
|
203
|
-
*
|
|
176
|
+
* shape the service stores: `deposit_account_id: '35'` becomes
|
|
177
|
+
* `deposit_account: {qbo_id: '35', account_id, account_name, …}`. Written at the
|
|
178
|
+
* request boundary rather than in the page's draft, so the UI keeps working in
|
|
179
|
+
* ids. An id that resolves to no account keeps its bare form rather than being
|
|
180
|
+
* dropped.
|
|
204
181
|
*/
|
|
205
182
|
export const withInvoicingQboMappedAccounts = (accountMappings, accountByQboId) => {
|
|
206
183
|
if (accountMappings == null) {
|
|
207
184
|
return undefined;
|
|
208
185
|
}
|
|
209
186
|
const expanded = { ...accountMappings };
|
|
210
|
-
|
|
211
|
-
const objectKey =
|
|
187
|
+
mappingCodesIn(accountMappings).forEach((code) => {
|
|
188
|
+
const objectKey = mappedAccountKeyForCode(code);
|
|
212
189
|
const accountId = getInvoicingQboAccountMappingId(accountMappings, code);
|
|
213
190
|
if (accountId == null) {
|
|
214
191
|
return;
|
|
215
192
|
}
|
|
216
193
|
const account = accountByQboId(accountId);
|
|
217
|
-
|
|
218
|
-
|
|
194
|
+
if (account == null) {
|
|
195
|
+
// Unresolved: leave the id as it stands rather than dropping the mapping.
|
|
196
|
+
// Sending less than we were given would unset a live configuration.
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
expanded[objectKey] = toAccountPayload(account);
|
|
219
200
|
expanded[code] = undefined;
|
|
220
201
|
});
|
|
221
202
|
return expanded;
|
|
222
203
|
};
|
|
223
204
|
export function withInvoicingQboAccountMappingId(accountMappings, code, accountId) {
|
|
224
|
-
// Both slots are written together
|
|
225
|
-
//
|
|
205
|
+
// Both slots are written together: setting only the bare id would leave the
|
|
206
|
+
// record shape behind, and the reader prefers it — so the selection just made
|
|
226
207
|
// would read back as whatever was mapped before.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
deposit_account: undefined,
|
|
233
|
-
deposit_account_id: accountId,
|
|
234
|
-
};
|
|
235
|
-
case 'default_income_account_id':
|
|
236
|
-
return {
|
|
237
|
-
...base,
|
|
238
|
-
default_income_account: undefined,
|
|
239
|
-
default_income_account_id: accountId,
|
|
240
|
-
};
|
|
241
|
-
case 'discounts_account_id':
|
|
242
|
-
return {
|
|
243
|
-
...base,
|
|
244
|
-
discounts_account: undefined,
|
|
245
|
-
discounts_account_id: accountId,
|
|
246
|
-
};
|
|
247
|
-
case 'rounding_account_id':
|
|
248
|
-
return {
|
|
249
|
-
...base,
|
|
250
|
-
rounding_account: undefined,
|
|
251
|
-
rounding_account_id: accountId,
|
|
252
|
-
};
|
|
253
|
-
case 'write_off_account_id':
|
|
254
|
-
return {
|
|
255
|
-
...base,
|
|
256
|
-
write_off_account: undefined,
|
|
257
|
-
write_off_account_id: accountId,
|
|
258
|
-
};
|
|
259
|
-
default:
|
|
260
|
-
return base;
|
|
261
|
-
}
|
|
208
|
+
return {
|
|
209
|
+
...(accountMappings ?? {}),
|
|
210
|
+
[mappedAccountKeyForCode(code)]: undefined,
|
|
211
|
+
[code]: accountId,
|
|
212
|
+
};
|
|
262
213
|
}
|
|
263
214
|
export function toInvoicingQboAccountMappingKindOption(option) {
|
|
264
215
|
return {
|
package/lib/esm/index.js
CHANGED
|
@@ -851,7 +851,6 @@ export { getInvoicingProductById } from './entity/invoicing/product/productSelec
|
|
|
851
851
|
// ── Invoicing: settings ───────────────────────────────────────────────────────
|
|
852
852
|
export { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, resetInvoicingBrandingFormDraft, resetInvoicingQboSettingsDraft, resetSaveInvoicingSettings, saveInvoicingSettings, submitInvoicingBrandingForm, submitInvoicingQboSettings, updateInvoicingBrandingFormDraft, updateInvoicingQboSettingsDraft, updateInvoicingSettings, } from './view/invoicing/settingsView/settingsViewReducer';
|
|
853
853
|
export { getInvoicingBrandingFormView, getInvoicingQboSettingsFormView, getInvoicingSettings, getInvoicingSettingsFetchState, getInvoicingSettingsHubView, getInvoicingSettingsView, } from './view/invoicing/settingsView/settingsViewSelector';
|
|
854
|
-
export { INVOICING_QBO_ACCOUNT_MAPPING_CODES, toInvoicingQboAccountMappingCode, } from './entity/invoicing/invoicingCommonPayload';
|
|
855
854
|
export { entityToInvoicingQboSettingsLocalData, initialInvoicingQboSettingsLocalData, invoicingQboSettingsLocalDataToPayload, } from './view/invoicing/settingsView/invoicingQboSettingsFormConfig';
|
|
856
855
|
export { INVOICING_BUSINESS_ADDRESS_TYPE, entityToInvoicingBrandingFormLocalData, initialInvoicingBrandingFormLocalData, } from './view/invoicing/settingsView/invoicingBrandingFormConfig';
|
|
857
856
|
export { isStripeConnectedFromSettings } from './view/invoicing/settingsView/invoicingSettingsHelpers';
|
|
@@ -52,7 +52,13 @@ export const invoicingQboAccountByQboId = (state, qboId) => {
|
|
|
52
52
|
// throw would take the whole request with it.
|
|
53
53
|
try {
|
|
54
54
|
const { accounts } = getAccountList(state.accountState, state.accountListState, INVOICING_ACCOUNT_LIST_KEY);
|
|
55
|
-
|
|
55
|
+
// Matched on any id the account is known by. The pickers submit `qboId`,
|
|
56
|
+
// but a mapping that arrived from the service can name the account by its
|
|
57
|
+
// platform id instead, and an account we cannot resolve is a mapping that
|
|
58
|
+
// cannot be sent as a record.
|
|
59
|
+
return accounts.find((account) => String(account.qboId) === qboId ||
|
|
60
|
+
String(account.accountId) === qboId ||
|
|
61
|
+
String(account.coaId) === qboId);
|
|
56
62
|
}
|
|
57
63
|
catch {
|
|
58
64
|
return undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getInvoicingQboAccountMappingId, withInvoicingQboAccountMappingId, } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
2
2
|
export const initialInvoicingQboSettingsLocalData = {
|
|
3
3
|
accountIdByMappingCode: {},
|
|
4
4
|
autoCreateItems: false,
|
|
@@ -10,9 +10,13 @@ export const initialInvoicingQboSettingsLocalData = {
|
|
|
10
10
|
};
|
|
11
11
|
/** The settings response as the page edits it. */
|
|
12
12
|
export const entityToInvoicingQboSettingsLocalData = (qbo) => {
|
|
13
|
+
const accountMappings = qbo?.account_mappings ?? {};
|
|
13
14
|
const accountIdByMappingCode = {};
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
// Whatever slots the payload carries, in either shape — `deposit_account` and
|
|
16
|
+
// `deposit_account_id` are the same mapping under one code.
|
|
17
|
+
Object.keys(accountMappings).forEach((key) => {
|
|
18
|
+
const code = key.endsWith('_id') ? key : `${key}_id`;
|
|
19
|
+
const accountId = getInvoicingQboAccountMappingId(accountMappings, code);
|
|
16
20
|
if (accountId != null) {
|
|
17
21
|
accountIdByMappingCode[code] = accountId;
|
|
18
22
|
}
|
|
@@ -34,8 +38,7 @@ export const entityToInvoicingQboSettingsLocalData = (qbo) => {
|
|
|
34
38
|
*/
|
|
35
39
|
export const invoicingQboSettingsLocalDataToPayload = (localData) => {
|
|
36
40
|
let accountMappings = {};
|
|
37
|
-
|
|
38
|
-
const accountId = localData.accountIdByMappingCode[code] ?? '';
|
|
41
|
+
Object.entries(localData.accountIdByMappingCode).forEach(([code, accountId]) => {
|
|
39
42
|
if (accountId !== '') {
|
|
40
43
|
accountMappings = withInvoicingQboAccountMappingId(accountMappings, code, accountId);
|
|
41
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getInvoicingQboAccountMappingId,
|
|
1
|
+
import { getInvoicingQboAccountMappingId, } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
2
2
|
import { getFormattedAddress } from '../../addressView/addressViewSelector';
|
|
3
3
|
import { getInvoicingConfigView } from '../invoicingConfigView/invoicingConfigViewSelector';
|
|
4
4
|
import { getInvoicingQboView, isInvoicingAccountingPickerDataLoading, } from '../invoicingQboView/invoicingQboViewSelector';
|
|
@@ -52,12 +52,7 @@ export function deriveInvoicingEnablePrerequisites(settings, isQboConnected, qbo
|
|
|
52
52
|
// configured would let `every` pass vacuously and unlock the button early.
|
|
53
53
|
const isQboConfigured = isQboConnected &&
|
|
54
54
|
qboAccountMappingKindOptions.length > 0 &&
|
|
55
|
-
qboAccountMappingKindOptions.every((option) =>
|
|
56
|
-
// A kind the client has no slot for cannot count as configured.
|
|
57
|
-
const code = toInvoicingQboAccountMappingCode(option.code);
|
|
58
|
-
return (code != null &&
|
|
59
|
-
getInvoicingQboAccountMappingId(accountMappings, code) != null);
|
|
60
|
-
});
|
|
55
|
+
qboAccountMappingKindOptions.every((option) => getInvoicingQboAccountMappingId(accountMappings, option.code) != null);
|
|
61
56
|
return {
|
|
62
57
|
canEnable: isStripeConnected && isQboConfigured,
|
|
63
58
|
isQboConfigured,
|
package/lib/index.d.ts
CHANGED
|
@@ -1240,8 +1240,6 @@ export { getInvoicingBrandingFormView, getInvoicingQboSettingsFormView, getInvoi
|
|
|
1240
1240
|
export type { InvoicingBrandingFormView, InvoicingQboSettingsFormView, InvoicingSettingsHubView, InvoicingSettingsView, } from './view/invoicing/settingsView/settingsViewSelector';
|
|
1241
1241
|
export type { InvoicingBrandingFormLocalData } from './view/invoicing/settingsView/invoicingBrandingFormConfig';
|
|
1242
1242
|
export type { InvoicingQboSettingsLocalData } from './view/invoicing/settingsView/invoicingQboSettingsFormConfig';
|
|
1243
|
-
export { INVOICING_QBO_ACCOUNT_MAPPING_CODES, toInvoicingQboAccountMappingCode, } from './entity/invoicing/invoicingCommonPayload';
|
|
1244
|
-
export type { InvoicingQboAccountMappingCode } from './entity/invoicing/invoicingCommonPayload';
|
|
1245
1243
|
export { entityToInvoicingQboSettingsLocalData, initialInvoicingQboSettingsLocalData, invoicingQboSettingsLocalDataToPayload, } from './view/invoicing/settingsView/invoicingQboSettingsFormConfig';
|
|
1246
1244
|
export { INVOICING_BUSINESS_ADDRESS_TYPE, entityToInvoicingBrandingFormLocalData, initialInvoicingBrandingFormLocalData, } from './view/invoicing/settingsView/invoicingBrandingFormConfig';
|
|
1247
1245
|
export { isStripeConnectedFromSettings } from './view/invoicing/settingsView/invoicingSettingsHelpers';
|
package/lib/index.js
CHANGED
|
@@ -83,7 +83,7 @@ exports.runInvoicingCatalogPlanAction = exports.getInvoicingInvoiceActionState =
|
|
|
83
83
|
exports.getInvoicingSetupIntentFetchState = exports.getInvoicingSetupIntent = exports.getInvoicingSentPaymentLinkMagicUrl = exports.getInvoicingSentPaymentLinkEmail = exports.getInvoicingPlaidLinkTokenFetchState = exports.getInvoicingPlaidLinkToken = exports.getInvoicingPaymentMethodSaveState = exports.getInvoicingPaymentLinkSendState = exports.sendInvoicingPaymentLink = exports.saveInvoicingPaymentMethod = exports.resetInvoicingCustomerPaymentMethod = exports.fetchInvoicingPlaidLinkToken = exports.createInvoicingSetupIntent = exports.getInvoicingCustomerDetail = exports.fetchInvoicingCustomerDetailPage = exports.fetchInvoicingCustomerDetail = exports.getInvoicingCustomerListView = exports.INVOICING_CUSTOMER_COLUMNS = exports.ALL_INVOICING_CUSTOMER_TAB_IDS = exports.ALL_INVOICING_CUSTOMER_SORT_KEYS = exports.updateInvoicingCustomerFilters = exports.setInvoicingCustomerActiveTab = exports.fetchInvoicingCustomerListPage = exports.fetchInvoicingCustomerList = exports.fetchInvoicingCustomerCounts = exports.updateInvoicingCustomers = exports.removeInvoicingCustomer = exports.INVOICING_LIST_PAGE_SIZE = exports.getInvoicingDataImportActionState = exports.uploadInvoicingMigrationFiles = exports.startInvoicingMigration = exports.rollbackInvoicingMigration = exports.retryInvoicingMigration = exports.connectInvoicingChargebee = exports.getInvoicingDataImportView = exports.setInvoicingActiveMigrationSessionId = exports.fetchInvoicingMigrationSessions = exports.fetchInvoicingMigrationSession = exports.fetchInvoicingMigrationDiagnostics = exports.fetchInvoicingDataImportStatus = exports.getInvoicingPaymentActionState = exports.runInvoicingPaymentAction = exports.getInvoicingDunningActionState = exports.runInvoicingDunningAction = exports.getInvoicingSubscriptionActionState = exports.runInvoicingSubscriptionAction = exports.getInvoicingDiscountActionState = exports.runInvoicingDiscountAction = exports.getInvoicingCatalogActionState = exports.runInvoicingCatalogProductAction = void 0;
|
|
84
84
|
exports.updateInvoicingCouponFilters = exports.setInvoicingCouponActiveTab = exports.fetchInvoicingCouponListPage = exports.fetchInvoicingCouponList = exports.fetchInvoicingCouponCounts = exports.updateInvoicingCoupons = exports.removeInvoicingCoupon = exports.getInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteById = exports.fetchInvoicingCreditNoteDetail = exports.getInvoicingCreditNoteListView = exports.INVOICING_CREDIT_NOTE_COLUMNS = exports.ALL_INVOICING_CREDIT_NOTE_TAB_IDS = exports.ALL_INVOICING_CREDIT_NOTE_SORT_KEYS = exports.updateInvoicingCreditNoteFilters = exports.setInvoicingCreditNoteActiveTab = exports.fetchInvoicingCreditNoteListPage = exports.fetchInvoicingCreditNoteList = exports.fetchInvoicingCreditNoteCounts = exports.updateInvoicingCreditNotes = exports.removeInvoicingCreditNote = exports.getInvoicingTransactionDetail = exports.getInvoicingTransactionById = exports.fetchInvoicingTransactionDetail = exports.getInvoicingTransactionListView = exports.INVOICING_TRANSACTION_COLUMNS = exports.ALL_INVOICING_TRANSACTION_TAB_IDS = exports.ALL_INVOICING_TRANSACTION_SORT_KEYS = exports.updateInvoicingTransactionFilters = exports.setInvoicingTransactionActiveTab = exports.fetchInvoicingTransactionListPage = exports.fetchInvoicingTransactionList = exports.updateInvoicingTransactions = exports.removeInvoicingTransaction = exports.getInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionById = exports.fetchInvoicingSubscriptionDetail = exports.getInvoicingSubscriptionListView = exports.INVOICING_SUBSCRIPTION_COLUMNS = exports.ALL_INVOICING_SUBSCRIPTION_TAB_IDS = exports.ALL_INVOICING_SUBSCRIPTION_SORT_KEYS = exports.updateInvoicingSubscriptionFilters = exports.setInvoicingSubscriptionActiveTab = exports.fetchInvoicingSubscriptionListPage = exports.fetchInvoicingSubscriptionList = exports.fetchInvoicingSubscriptionCounts = exports.updateInvoicingSubscriptions = exports.removeInvoicingSubscription = exports.resetPromotionalCreditAction = exports.submitAddPromotionalCredits = void 0;
|
|
85
85
|
exports.connectInvoicingStripe = exports.getInvoicingProductById = exports.getInvoicingPlanById = exports.getInvoicingCatalogItemDetail = exports.fetchInvoicingCatalogItemDetail = exports.getInvoicingCatalogListView = exports.INVOICING_PRODUCT_COLUMNS = exports.ALL_INVOICING_PRODUCT_SORT_KEYS = exports.updateInvoicingCatalogProductFilters = exports.updateInvoicingCatalogPlanFilters = exports.fetchInvoicingCatalogProductList = exports.fetchInvoicingCatalogPlanList = exports.fetchInvoicingCatalogListPage = exports.fetchInvoicingCatalogCounts = exports.updateInvoicingProducts = exports.removeInvoicingProduct = exports.updateInvoicingPlans = exports.removeInvoicingPlan = exports.mergeInvoicingPlanSubFamily = exports.getInvoicingDunningEmailPreview = exports.getInvoicingDunningCaseDetail = exports.getInvoicingDunningCaseById = exports.invalidateInvoicingDunningEmailPreview = exports.fetchInvoicingDunningEmailPreviewPage = exports.fetchInvoicingDunningCaseDetail = exports.clearInvoicingDunningCaseDetailView = exports.getInvoicingDunningCaseListView = exports.INVOICING_DUNNING_CASE_COLUMNS = exports.ALL_INVOICING_DUNNING_CASE_TAB_IDS = exports.ALL_INVOICING_DUNNING_CASE_SORT_KEYS = exports.updateInvoicingDunningCaseFilters = exports.setInvoicingDunningCaseActiveTab = exports.fetchInvoicingDunningCaseListPage = exports.fetchInvoicingDunningCaseList = exports.fetchInvoicingDunningCaseCounts = exports.updateInvoicingDunningCases = exports.removeInvoicingDunningCase = exports.getInvoicingCouponDetail = exports.fetchInvoicingCouponDetail = exports.getInvoicingCouponById = exports.getInvoicingCouponListView = exports.getInvoicingCouponListNextCursor = exports.getInvoicingCouponListItems = exports.getInvoicingCouponListHasMore = exports.getInvoicingCouponListFilters = exports.getInvoicingCouponListFetchState = exports.getInvoicingCouponCounts = exports.INVOICING_COUPON_COLUMNS = exports.ALL_INVOICING_COUPON_TAB_IDS = exports.ALL_INVOICING_COUPON_SORT_KEYS = void 0;
|
|
86
|
-
exports.getInvoicingOnboardingGateView = exports.getInvoicingConfigView = exports.updateInvoicingConfig = exports.resetInvoicingConfigActionStates = exports.fetchInvoicingConfig = exports.enableInvoicing = exports.acceptInvoicingTerms = exports.withInvoicingQboAccountMappingId = exports.toInvoicingQboCustomerMatchingMode = exports.toInvoicingNamedOptionsByKey = exports.getInvoicingQboAccountMappingId = exports.INVOICING_QBO_CUSTOMER_MATCHING_MODES = exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.startInvoicingQboBackfill = exports.retryInvoicingQboSyncTask = exports.fetchInvoicingQboSyncHealth = exports.fetchInvoicingQboConnection = exports.fetchInvoicingAccountingPickers = exports.isStripeConnectedFromSettings = exports.initialInvoicingBrandingFormLocalData = exports.entityToInvoicingBrandingFormLocalData = exports.INVOICING_BUSINESS_ADDRESS_TYPE = exports.invoicingQboSettingsLocalDataToPayload = exports.initialInvoicingQboSettingsLocalData = exports.entityToInvoicingQboSettingsLocalData = exports.
|
|
86
|
+
exports.getInvoicingOnboardingGateView = exports.getInvoicingConfigView = exports.updateInvoicingConfig = exports.resetInvoicingConfigActionStates = exports.fetchInvoicingConfig = exports.enableInvoicing = exports.acceptInvoicingTerms = exports.withInvoicingQboAccountMappingId = exports.toInvoicingQboCustomerMatchingMode = exports.toInvoicingNamedOptionsByKey = exports.getInvoicingQboAccountMappingId = exports.INVOICING_QBO_CUSTOMER_MATCHING_MODES = exports.getInvoicingQboView = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.startInvoicingQboBackfill = exports.retryInvoicingQboSyncTask = exports.fetchInvoicingQboSyncHealth = exports.fetchInvoicingQboConnection = exports.fetchInvoicingAccountingPickers = exports.isStripeConnectedFromSettings = exports.initialInvoicingBrandingFormLocalData = exports.entityToInvoicingBrandingFormLocalData = exports.INVOICING_BUSINESS_ADDRESS_TYPE = exports.invoicingQboSettingsLocalDataToPayload = exports.initialInvoicingQboSettingsLocalData = exports.entityToInvoicingQboSettingsLocalData = exports.getInvoicingSettingsView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = exports.getInvoicingQboSettingsFormView = exports.getInvoicingBrandingFormView = exports.updateInvoicingSettings = exports.updateInvoicingQboSettingsDraft = exports.updateInvoicingBrandingFormDraft = exports.submitInvoicingQboSettings = exports.submitInvoicingBrandingForm = exports.saveInvoicingSettings = exports.resetSaveInvoicingSettings = exports.resetInvoicingQboSettingsDraft = exports.resetInvoicingBrandingFormDraft = exports.fetchInvoicingSettings = exports.disconnectInvoicingStripe = void 0;
|
|
87
87
|
const allowedValue_1 = require("./commonStateTypes/allowedValue");
|
|
88
88
|
Object.defineProperty(exports, "isAllowedValueWithCode", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithCode; } });
|
|
89
89
|
Object.defineProperty(exports, "isAllowedValueWithID", { enumerable: true, get: function () { return allowedValue_1.isAllowedValueWithID; } });
|
|
@@ -3106,9 +3106,6 @@ Object.defineProperty(exports, "getInvoicingSettings", { enumerable: true, get:
|
|
|
3106
3106
|
Object.defineProperty(exports, "getInvoicingSettingsFetchState", { enumerable: true, get: function () { return settingsViewSelector_2.getInvoicingSettingsFetchState; } });
|
|
3107
3107
|
Object.defineProperty(exports, "getInvoicingSettingsHubView", { enumerable: true, get: function () { return settingsViewSelector_2.getInvoicingSettingsHubView; } });
|
|
3108
3108
|
Object.defineProperty(exports, "getInvoicingSettingsView", { enumerable: true, get: function () { return settingsViewSelector_2.getInvoicingSettingsView; } });
|
|
3109
|
-
var invoicingCommonPayload_2 = require("./entity/invoicing/invoicingCommonPayload");
|
|
3110
|
-
Object.defineProperty(exports, "INVOICING_QBO_ACCOUNT_MAPPING_CODES", { enumerable: true, get: function () { return invoicingCommonPayload_2.INVOICING_QBO_ACCOUNT_MAPPING_CODES; } });
|
|
3111
|
-
Object.defineProperty(exports, "toInvoicingQboAccountMappingCode", { enumerable: true, get: function () { return invoicingCommonPayload_2.toInvoicingQboAccountMappingCode; } });
|
|
3112
3109
|
var invoicingQboSettingsFormConfig_1 = require("./view/invoicing/settingsView/invoicingQboSettingsFormConfig");
|
|
3113
3110
|
Object.defineProperty(exports, "entityToInvoicingQboSettingsLocalData", { enumerable: true, get: function () { return invoicingQboSettingsFormConfig_1.entityToInvoicingQboSettingsLocalData; } });
|
|
3114
3111
|
Object.defineProperty(exports, "initialInvoicingQboSettingsLocalData", { enumerable: true, get: function () { return invoicingQboSettingsFormConfig_1.initialInvoicingQboSettingsLocalData; } });
|
|
@@ -3131,12 +3128,12 @@ Object.defineProperty(exports, "INVOICING_INCOME_ACCOUNT_TYPES", { enumerable: t
|
|
|
3131
3128
|
Object.defineProperty(exports, "invoicingAccountsForQboAccountTypes", { enumerable: true, get: function () { return invoicingQboViewSelector_1.invoicingAccountsForQboAccountTypes; } });
|
|
3132
3129
|
var invoicingQboViewSelector_2 = require("./view/invoicing/invoicingQboView/invoicingQboViewSelector");
|
|
3133
3130
|
Object.defineProperty(exports, "getInvoicingQboView", { enumerable: true, get: function () { return invoicingQboViewSelector_2.getInvoicingQboView; } });
|
|
3134
|
-
var
|
|
3135
|
-
Object.defineProperty(exports, "INVOICING_QBO_CUSTOMER_MATCHING_MODES", { enumerable: true, get: function () { return
|
|
3136
|
-
Object.defineProperty(exports, "getInvoicingQboAccountMappingId", { enumerable: true, get: function () { return
|
|
3137
|
-
Object.defineProperty(exports, "toInvoicingNamedOptionsByKey", { enumerable: true, get: function () { return
|
|
3138
|
-
Object.defineProperty(exports, "toInvoicingQboCustomerMatchingMode", { enumerable: true, get: function () { return
|
|
3139
|
-
Object.defineProperty(exports, "withInvoicingQboAccountMappingId", { enumerable: true, get: function () { return
|
|
3131
|
+
var invoicingCommonPayload_2 = require("./entity/invoicing/invoicingCommonPayload");
|
|
3132
|
+
Object.defineProperty(exports, "INVOICING_QBO_CUSTOMER_MATCHING_MODES", { enumerable: true, get: function () { return invoicingCommonPayload_2.INVOICING_QBO_CUSTOMER_MATCHING_MODES; } });
|
|
3133
|
+
Object.defineProperty(exports, "getInvoicingQboAccountMappingId", { enumerable: true, get: function () { return invoicingCommonPayload_2.getInvoicingQboAccountMappingId; } });
|
|
3134
|
+
Object.defineProperty(exports, "toInvoicingNamedOptionsByKey", { enumerable: true, get: function () { return invoicingCommonPayload_2.toInvoicingNamedOptionsByKey; } });
|
|
3135
|
+
Object.defineProperty(exports, "toInvoicingQboCustomerMatchingMode", { enumerable: true, get: function () { return invoicingCommonPayload_2.toInvoicingQboCustomerMatchingMode; } });
|
|
3136
|
+
Object.defineProperty(exports, "withInvoicingQboAccountMappingId", { enumerable: true, get: function () { return invoicingCommonPayload_2.withInvoicingQboAccountMappingId; } });
|
|
3140
3137
|
// ── Invoicing: config ─────────────────────────────────────────────────────────
|
|
3141
3138
|
var invoicingConfigViewReducer_1 = require("./view/invoicing/invoicingConfigView/invoicingConfigViewReducer");
|
|
3142
3139
|
Object.defineProperty(exports, "acceptInvoicingTerms", { enumerable: true, get: function () { return invoicingConfigViewReducer_1.acceptInvoicingTerms; } });
|
|
@@ -58,7 +58,13 @@ const invoicingQboAccountByQboId = (state, qboId) => {
|
|
|
58
58
|
// throw would take the whole request with it.
|
|
59
59
|
try {
|
|
60
60
|
const { accounts } = (0, accountListSelector_1.getAccountList)(state.accountState, state.accountListState, exports.INVOICING_ACCOUNT_LIST_KEY);
|
|
61
|
-
|
|
61
|
+
// Matched on any id the account is known by. The pickers submit `qboId`,
|
|
62
|
+
// but a mapping that arrived from the service can name the account by its
|
|
63
|
+
// platform id instead, and an account we cannot resolve is a mapping that
|
|
64
|
+
// cannot be sent as a record.
|
|
65
|
+
return accounts.find((account) => String(account.qboId) === qboId ||
|
|
66
|
+
String(account.accountId) === qboId ||
|
|
67
|
+
String(account.coaId) === qboId);
|
|
62
68
|
}
|
|
63
69
|
catch {
|
|
64
70
|
return undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InvoicingQboSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
|
|
2
2
|
/**
|
|
3
3
|
* The QBO configuration page's local data. A client shape, not the wire one: the
|
|
4
4
|
* page edits a flat `accountIdByMappingCode` map keyed by the config's mapping
|
|
@@ -7,8 +7,13 @@ import { InvoicingQboAccountMappingCode, InvoicingQboSettingsPayload } from '../
|
|
|
7
7
|
* {@link invoicingQboSettingsLocalDataToPayload} convert at the boundary.
|
|
8
8
|
*/
|
|
9
9
|
export interface InvoicingQboSettingsLocalData {
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Mapping code to the QuickBooks account id the picker selected. Keyed by the
|
|
12
|
+
* config's own codes rather than a client-side list: the backend owns which
|
|
13
|
+
* slots exist, so anything narrower silently drops the ones it has not heard
|
|
14
|
+
* of.
|
|
15
|
+
*/
|
|
16
|
+
accountIdByMappingCode: Record<string, string>;
|
|
12
17
|
autoCreateItems: boolean;
|
|
13
18
|
closedPeriodVoidAsCreditMemo: boolean;
|
|
14
19
|
customerMatching: string;
|
|
@@ -13,9 +13,13 @@ exports.initialInvoicingQboSettingsLocalData = {
|
|
|
13
13
|
};
|
|
14
14
|
/** The settings response as the page edits it. */
|
|
15
15
|
const entityToInvoicingQboSettingsLocalData = (qbo) => {
|
|
16
|
+
const accountMappings = qbo?.account_mappings ?? {};
|
|
16
17
|
const accountIdByMappingCode = {};
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
// Whatever slots the payload carries, in either shape — `deposit_account` and
|
|
19
|
+
// `deposit_account_id` are the same mapping under one code.
|
|
20
|
+
Object.keys(accountMappings).forEach((key) => {
|
|
21
|
+
const code = key.endsWith('_id') ? key : `${key}_id`;
|
|
22
|
+
const accountId = (0, invoicingCommonPayload_1.getInvoicingQboAccountMappingId)(accountMappings, code);
|
|
19
23
|
if (accountId != null) {
|
|
20
24
|
accountIdByMappingCode[code] = accountId;
|
|
21
25
|
}
|
|
@@ -38,8 +42,7 @@ exports.entityToInvoicingQboSettingsLocalData = entityToInvoicingQboSettingsLoca
|
|
|
38
42
|
*/
|
|
39
43
|
const invoicingQboSettingsLocalDataToPayload = (localData) => {
|
|
40
44
|
let accountMappings = {};
|
|
41
|
-
|
|
42
|
-
const accountId = localData.accountIdByMappingCode[code] ?? '';
|
|
45
|
+
Object.entries(localData.accountIdByMappingCode).forEach(([code, accountId]) => {
|
|
43
46
|
if (accountId !== '') {
|
|
44
47
|
accountMappings = (0, invoicingCommonPayload_1.withInvoicingQboAccountMappingId)(accountMappings, code, accountId);
|
|
45
48
|
}
|
|
@@ -59,12 +59,7 @@ function deriveInvoicingEnablePrerequisites(settings, isQboConnected, qboAccount
|
|
|
59
59
|
// configured would let `every` pass vacuously and unlock the button early.
|
|
60
60
|
const isQboConfigured = isQboConnected &&
|
|
61
61
|
qboAccountMappingKindOptions.length > 0 &&
|
|
62
|
-
qboAccountMappingKindOptions.every((option) =>
|
|
63
|
-
// A kind the client has no slot for cannot count as configured.
|
|
64
|
-
const code = (0, invoicingCommonPayload_1.toInvoicingQboAccountMappingCode)(option.code);
|
|
65
|
-
return (code != null &&
|
|
66
|
-
(0, invoicingCommonPayload_1.getInvoicingQboAccountMappingId)(accountMappings, code) != null);
|
|
67
|
-
});
|
|
62
|
+
qboAccountMappingKindOptions.every((option) => (0, invoicingCommonPayload_1.getInvoicingQboAccountMappingId)(accountMappings, option.code) != null);
|
|
68
63
|
return {
|
|
69
64
|
canEnable: isStripeConnected && isQboConfigured,
|
|
70
65
|
isQboConfigured,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.2.10-
|
|
3
|
+
"version": "5.2.10-betaAK4",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|