@zeniai/client-epic-state 5.2.7-betaAK1 → 5.2.7-betaAK2

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.
@@ -159,12 +159,16 @@ function toInvoicingQboCustomerMatchingMode(value) {
159
159
  * shows its placeholder rather than selecting nothing.
160
160
  */
161
161
  function readInvoicingQboMappedAccountId(mappedAccount, legacyAccountId) {
162
- const objectId = mappedAccount?.account_id ?? '';
163
- if (objectId !== '') {
164
- return objectId;
165
- }
166
- const flatId = legacyAccountId ?? '';
167
- return flatId !== '' ? flatId : undefined;
162
+ // `qbo_id` first: the pickers key their options on the QuickBooks id, so an
163
+ // internal `account_id` would not select anything even when it is the same
164
+ // account. Both are read because the mapping arrives either way depending on
165
+ // how it was saved.
166
+ const candidates = [
167
+ mappedAccount?.qbo_id,
168
+ mappedAccount?.account_id,
169
+ legacyAccountId,
170
+ ];
171
+ return candidates.find((candidate) => candidate != null && candidate !== '');
168
172
  }
169
173
  /**
170
174
  * Read one account-mapping dropdown value by its config `code` (the codes in
@@ -134,12 +134,16 @@ export function toInvoicingQboCustomerMatchingMode(value) {
134
134
  * shows its placeholder rather than selecting nothing.
135
135
  */
136
136
  function readInvoicingQboMappedAccountId(mappedAccount, legacyAccountId) {
137
- const objectId = mappedAccount?.account_id ?? '';
138
- if (objectId !== '') {
139
- return objectId;
140
- }
141
- const flatId = legacyAccountId ?? '';
142
- return flatId !== '' ? flatId : undefined;
137
+ // `qbo_id` first: the pickers key their options on the QuickBooks id, so an
138
+ // internal `account_id` would not select anything even when it is the same
139
+ // account. Both are read because the mapping arrives either way depending on
140
+ // how it was saved.
141
+ const candidates = [
142
+ mappedAccount?.qbo_id,
143
+ mappedAccount?.account_id,
144
+ legacyAccountId,
145
+ ];
146
+ return candidates.find((candidate) => candidate != null && candidate !== '');
143
147
  }
144
148
  /**
145
149
  * Read one account-mapping dropdown value by its config `code` (the codes in
@@ -12,14 +12,23 @@ export const isInvoicingQboConnected = (state) => state.invoicingQboViewState.co
12
12
  * must not sit behind a skeleton waiting for lists it will never show.
13
13
  */
14
14
  export const isInvoicingAccountingPickerDataLoading = (state) => {
15
+ const isPending = (fetchState) => fetchState === 'Not-Started' || fetchState === 'In-Progress';
16
+ // The connection settles first and decides whether the lists are fetched at
17
+ // all, so it counts as loading too. Reporting "not loading" while it is in
18
+ // flight renders the form, then takes it away again the moment the tenant
19
+ // turns out to be connected.
20
+ if (isPending(getInvoicingQboConnectionFetchState(state).fetchState)) {
21
+ return true;
22
+ }
15
23
  if (!isInvoicingQboConnected(state)) {
16
24
  return false;
17
25
  }
18
26
  const accountList = state.accountListState.byReportId[INVOICING_ACCOUNT_LIST_KEY];
19
- const isPending = (fetchState) => fetchState === 'Not-Started' || fetchState === 'In-Progress';
20
27
  return (isPending(accountList.fetchState) ||
21
28
  isPending(state.classListState.fetchState));
22
29
  };
30
+ /** The QBO connection fetch on its own, without building the bundled view. */
31
+ export const getInvoicingQboConnectionFetchState = (state) => state.invoicingQboViewState.connectionFetchState;
23
32
  /**
24
33
  * Account types that can back invoicing revenue. Named here so screens ask for
25
34
  * "income accounts" rather than repeating the accounting service's vocabulary.
@@ -13,6 +13,8 @@ export declare const isInvoicingQboConnected: (state: RootState) => boolean;
13
13
  * must not sit behind a skeleton waiting for lists it will never show.
14
14
  */
15
15
  export declare const isInvoicingAccountingPickerDataLoading: (state: RootState) => boolean;
16
+ /** The QBO connection fetch on its own, without building the bundled view. */
17
+ export declare const getInvoicingQboConnectionFetchState: (state: RootState) => FetchStateAndError;
16
18
  /**
17
19
  * Account types that can back invoicing revenue. Named here so screens ask for
18
20
  * "income accounts" rather than repeating the accounting service's vocabulary.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInvoicingQboView = exports.invoicingAccountHierarchyForTypes = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
3
+ exports.getInvoicingQboView = exports.invoicingAccountHierarchyForTypes = exports.invoicingAccountsForQboAccountTypes = exports.INVOICING_INCOME_ACCOUNT_TYPES = exports.getInvoicingQboConnectionFetchState = exports.isInvoicingAccountingPickerDataLoading = exports.isInvoicingQboConnected = exports.INVOICING_ACCOUNT_LIST_KEY = void 0;
4
4
  const accountListSelector_1 = require("../../accountList/accountListSelector");
5
5
  const classListSelector_1 = require("../../classList/classListSelector");
6
6
  // The shared bucket, fetched with the same arguments as the other consumers so
@@ -16,15 +16,25 @@ exports.isInvoicingQboConnected = isInvoicingQboConnected;
16
16
  * must not sit behind a skeleton waiting for lists it will never show.
17
17
  */
18
18
  const isInvoicingAccountingPickerDataLoading = (state) => {
19
+ const isPending = (fetchState) => fetchState === 'Not-Started' || fetchState === 'In-Progress';
20
+ // The connection settles first and decides whether the lists are fetched at
21
+ // all, so it counts as loading too. Reporting "not loading" while it is in
22
+ // flight renders the form, then takes it away again the moment the tenant
23
+ // turns out to be connected.
24
+ if (isPending((0, exports.getInvoicingQboConnectionFetchState)(state).fetchState)) {
25
+ return true;
26
+ }
19
27
  if (!(0, exports.isInvoicingQboConnected)(state)) {
20
28
  return false;
21
29
  }
22
30
  const accountList = state.accountListState.byReportId[exports.INVOICING_ACCOUNT_LIST_KEY];
23
- const isPending = (fetchState) => fetchState === 'Not-Started' || fetchState === 'In-Progress';
24
31
  return (isPending(accountList.fetchState) ||
25
32
  isPending(state.classListState.fetchState));
26
33
  };
27
34
  exports.isInvoicingAccountingPickerDataLoading = isInvoicingAccountingPickerDataLoading;
35
+ /** The QBO connection fetch on its own, without building the bundled view. */
36
+ const getInvoicingQboConnectionFetchState = (state) => state.invoicingQboViewState.connectionFetchState;
37
+ exports.getInvoicingQboConnectionFetchState = getInvoicingQboConnectionFetchState;
28
38
  /**
29
39
  * Account types that can back invoicing revenue. Named here so screens ask for
30
40
  * "income accounts" rather than repeating the accounting service's vocabulary.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.7-betaAK1",
3
+ "version": "5.2.7-betaAK2",
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",