@zeniai/client-epic-state 5.2.96 → 5.2.97-beta1KB

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.
@@ -128,7 +128,6 @@ export const prepareCreateTransactionPayload = (state, localData) => {
128
128
  if (transactionType === 'journal_entry') {
129
129
  return {
130
130
  ...base,
131
- document_id: localData.documentId,
132
131
  lines,
133
132
  };
134
133
  }
@@ -142,6 +141,8 @@ export const prepareCreateTransactionPayload = (state, localData) => {
142
141
  if (transactionType === 'check') {
143
142
  return {
144
143
  ...purchaseBase,
144
+ // The form has no payment method field for a check; it is always paid by check.
145
+ payment_type: 'check',
145
146
  document_number: localData.documentNumber,
146
147
  print_status: localData.printStatus,
147
148
  remit_to_address: toRemitToAddressPayload(localData.remitToAddress),
@@ -1,4 +1,5 @@
1
1
  import { createSelector } from '@reduxjs/toolkit';
2
+ import { getAccountBase } from '../../../entity/account/accountSelector';
2
3
  import { getAccountListFetchState, getNestedAccountListHierarchy, } from '../../accountList/accountListSelector';
3
4
  import { getNestedClassListHierarchy } from '../../classList/classListSelector';
4
5
  import { getResolvedTransferAccounts } from '../../createTransferEntry/createTransferEntrySelector';
@@ -22,6 +23,9 @@ export const getCreateTransactionVendorRecommendations = (state, vendorQboId) =>
22
23
  recommendations: view.recommendations,
23
24
  };
24
25
  };
26
+ /** QBO keeps a sub-account on its parent's type, so filtering the roots is enough. */
27
+ const getBankAccountsOnly = (accountState, hierarchy) => hierarchy.filter((node) => getAccountBase(accountState, node.accountId[0], 'account_list')
28
+ ?.accountType === 'bank');
25
29
  /**
26
30
  * Memoized: app-ui reads this straight from useSelector, and the vendor list and hierarchies are
27
31
  * rebuilt on every call, so an unmemoized version re-renders the page on every store action.
@@ -30,22 +34,28 @@ export const getCreateTransactionView = createSelector([
30
34
  (state) => state.transactionDetailState.createTransactionsState,
31
35
  (state) => state.vendorState.vendorByID,
32
36
  (state) => state.accountListState,
37
+ (state) => state.accountState,
33
38
  (state) => state.classListState,
34
39
  (state) => getResolvedTransferAccounts(state).transferAccountsList,
35
40
  (_state, transactionType) => transactionType,
36
- ], (createTransactionsState, vendorByID, accountListState, classListState, transferAccountsList, transactionType) => ({
37
- transactionType,
38
- localData: createTransactionsState.newTransactionState[transactionType],
39
- createStatus: createTransactionsState.createStatus,
40
- createdTransactionId: createTransactionsState.createdTransactionId,
41
- vendorList: Object.values(vendorByID),
42
- accountListFetchState: getAccountListFetchState(accountListState, 'accountList'),
43
- lineAccountListFetchState: getAccountListFetchState(accountListState, 'createTransactionLineAccountList'),
44
- paymentAccountListFetchState: getAccountListFetchState(accountListState, 'createTransactionPaymentAccountList'),
45
- accountListNestedAccountHierarchy: getNestedAccountListHierarchy(accountListState, 'createTransactionLineAccountList'),
46
- paymentAccountListNestedAccountHierarchy: getNestedAccountListHierarchy(accountListState, 'createTransactionPaymentAccountList'),
47
- classListNestedAccountHierarchy: getNestedClassListHierarchy(classListState),
48
- transferAccountsList: transactionType === 'transfer' ? transferAccountsList : [],
49
- fetchState: createTransactionsState.createStatus.fetchState,
50
- error: createTransactionsState.createStatus.error,
51
- }));
41
+ ], (createTransactionsState, vendorByID, accountListState, accountState, classListState, transferAccountsList, transactionType) => {
42
+ const paymentAccountListNestedAccountHierarchy = getNestedAccountListHierarchy(accountListState, 'createTransactionPaymentAccountList');
43
+ return {
44
+ transactionType,
45
+ localData: createTransactionsState.newTransactionState[transactionType],
46
+ createStatus: createTransactionsState.createStatus,
47
+ createdTransactionId: createTransactionsState.createdTransactionId,
48
+ vendorList: Object.values(vendorByID),
49
+ accountListFetchState: getAccountListFetchState(accountListState, 'accountList'),
50
+ lineAccountListFetchState: getAccountListFetchState(accountListState, 'createTransactionLineAccountList'),
51
+ paymentAccountListFetchState: getAccountListFetchState(accountListState, 'createTransactionPaymentAccountList'),
52
+ accountListNestedAccountHierarchy: getNestedAccountListHierarchy(accountListState, 'createTransactionLineAccountList'),
53
+ paymentAccountListNestedAccountHierarchy: transactionType === 'check'
54
+ ? getBankAccountsOnly(accountState, paymentAccountListNestedAccountHierarchy)
55
+ : paymentAccountListNestedAccountHierarchy,
56
+ classListNestedAccountHierarchy: getNestedClassListHierarchy(classListState),
57
+ transferAccountsList: transactionType === 'transfer' ? transferAccountsList : [],
58
+ fetchState: createTransactionsState.createStatus.fetchState,
59
+ error: createTransactionsState.createStatus.error,
60
+ };
61
+ });
@@ -12,8 +12,8 @@ import { CreateTransactionLocalData } from './createTransactionState';
12
12
  * 1. `line_detail_type` is snake_case. The PascalCase strings in the backend are Python
13
13
  * constant NAMES; ZENI_LINE_DETAIL_TYPE_TO_QBO_LINE_DETAIL_TYPE_MAP converts them for the
14
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`.
15
+ * 2. Only the QBO Purchases (check, credit_card_credit) send a reference number, as
16
+ * `document_number`. A journal entry sends none.
17
17
  */
18
18
  export interface CreateTransactionAccountPayload {
19
19
  qbo_id: ID;
@@ -51,8 +51,6 @@ export interface CreateTransactionRemitToAddressPayload {
51
51
  export interface CreateTransactionRequest extends Record<string, unknown> {
52
52
  transaction_date: string;
53
53
  transaction_type: string;
54
- /** journal_entry reference number. */
55
- document_id?: string;
56
54
  /** check / credit_card_credit reference number (QBO Purchase). */
57
55
  document_number?: string;
58
56
  from_account_id?: ID;
@@ -132,7 +132,6 @@ const prepareCreateTransactionPayload = (state, localData) => {
132
132
  if (transactionType === 'journal_entry') {
133
133
  return {
134
134
  ...base,
135
- document_id: localData.documentId,
136
135
  lines,
137
136
  };
138
137
  }
@@ -146,6 +145,8 @@ const prepareCreateTransactionPayload = (state, localData) => {
146
145
  if (transactionType === 'check') {
147
146
  return {
148
147
  ...purchaseBase,
148
+ // The form has no payment method field for a check; it is always paid by check.
149
+ payment_type: 'check',
149
150
  document_number: localData.documentNumber,
150
151
  print_status: localData.printStatus,
151
152
  remit_to_address: toRemitToAddressPayload(localData.remitToAddress),
@@ -22,7 +22,10 @@ export interface CreateTransactionView extends SelectorView {
22
22
  lineAccountListFetchState: FetchState;
23
23
  localData: CreateTransactionLocalData;
24
24
  paymentAccountListFetchState: FetchState;
25
- /** Bank, credit card and other current asset accounts for the header payment account. */
25
+ /**
26
+ * Bank, credit card and other current asset accounts for the header payment account; bank
27
+ * accounts only for a check.
28
+ */
26
29
  paymentAccountListNestedAccountHierarchy: NestedAccountHierarchyForReport[];
27
30
  transactionType: CreatableTransactionType;
28
31
  /** Populated for transfer only; the COA would offer ineligible accounts. */
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCreateTransactionView = exports.getCreateTransactionVendorRecommendations = exports.getCreateTransactionStatus = exports.getCreateTransactionLocalData = void 0;
4
4
  const toolkit_1 = require("@reduxjs/toolkit");
5
+ const accountSelector_1 = require("../../../entity/account/accountSelector");
5
6
  const accountListSelector_1 = require("../../accountList/accountListSelector");
6
7
  const classListSelector_1 = require("../../classList/classListSelector");
7
8
  const createTransferEntrySelector_1 = require("../../createTransferEntry/createTransferEntrySelector");
@@ -28,6 +29,9 @@ const getCreateTransactionVendorRecommendations = (state, vendorQboId) => {
28
29
  };
29
30
  };
30
31
  exports.getCreateTransactionVendorRecommendations = getCreateTransactionVendorRecommendations;
32
+ /** QBO keeps a sub-account on its parent's type, so filtering the roots is enough. */
33
+ const getBankAccountsOnly = (accountState, hierarchy) => hierarchy.filter((node) => (0, accountSelector_1.getAccountBase)(accountState, node.accountId[0], 'account_list')
34
+ ?.accountType === 'bank');
31
35
  /**
32
36
  * Memoized: app-ui reads this straight from useSelector, and the vendor list and hierarchies are
33
37
  * rebuilt on every call, so an unmemoized version re-renders the page on every store action.
@@ -36,22 +40,28 @@ exports.getCreateTransactionView = (0, toolkit_1.createSelector)([
36
40
  (state) => state.transactionDetailState.createTransactionsState,
37
41
  (state) => state.vendorState.vendorByID,
38
42
  (state) => state.accountListState,
43
+ (state) => state.accountState,
39
44
  (state) => state.classListState,
40
45
  (state) => (0, createTransferEntrySelector_1.getResolvedTransferAccounts)(state).transferAccountsList,
41
46
  (_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
- accountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'accountList'),
49
- lineAccountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'createTransactionLineAccountList'),
50
- paymentAccountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'createTransactionPaymentAccountList'),
51
- accountListNestedAccountHierarchy: (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'createTransactionLineAccountList'),
52
- paymentAccountListNestedAccountHierarchy: (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'createTransactionPaymentAccountList'),
53
- classListNestedAccountHierarchy: (0, classListSelector_1.getNestedClassListHierarchy)(classListState),
54
- transferAccountsList: transactionType === 'transfer' ? transferAccountsList : [],
55
- fetchState: createTransactionsState.createStatus.fetchState,
56
- error: createTransactionsState.createStatus.error,
57
- }));
47
+ ], (createTransactionsState, vendorByID, accountListState, accountState, classListState, transferAccountsList, transactionType) => {
48
+ const paymentAccountListNestedAccountHierarchy = (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'createTransactionPaymentAccountList');
49
+ return {
50
+ transactionType,
51
+ localData: createTransactionsState.newTransactionState[transactionType],
52
+ createStatus: createTransactionsState.createStatus,
53
+ createdTransactionId: createTransactionsState.createdTransactionId,
54
+ vendorList: Object.values(vendorByID),
55
+ accountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'accountList'),
56
+ lineAccountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'createTransactionLineAccountList'),
57
+ paymentAccountListFetchState: (0, accountListSelector_1.getAccountListFetchState)(accountListState, 'createTransactionPaymentAccountList'),
58
+ accountListNestedAccountHierarchy: (0, accountListSelector_1.getNestedAccountListHierarchy)(accountListState, 'createTransactionLineAccountList'),
59
+ paymentAccountListNestedAccountHierarchy: transactionType === 'check'
60
+ ? getBankAccountsOnly(accountState, paymentAccountListNestedAccountHierarchy)
61
+ : paymentAccountListNestedAccountHierarchy,
62
+ classListNestedAccountHierarchy: (0, classListSelector_1.getNestedClassListHierarchy)(classListState),
63
+ transferAccountsList: transactionType === 'transfer' ? transferAccountsList : [],
64
+ fetchState: createTransactionsState.createStatus.fetchState,
65
+ error: createTransactionsState.createStatus.error,
66
+ };
67
+ });
@@ -54,8 +54,6 @@ export interface CreateTransactionLocalData {
54
54
  /** Empty for transfer, which has no lines at all. */
55
55
  lines: CreateTransactionLineLocalData[];
56
56
  transactionType: CreatableTransactionType;
57
- /** journal_entry reference number. */
58
- documentId?: string;
59
57
  /** check / credit_card_credit reference number. */
60
58
  documentNumber?: string;
61
59
  /** transfer */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.96",
3
+ "version": "5.2.97-beta1KB",
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",