@zeniai/client-epic-state 5.3.2 → 5.3.3-beta0KB

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.
@@ -26,9 +26,10 @@ export const fetchReconciliationViewEpic = (actions$, state$, zeniAPI) => action
26
26
  }
27
27
  let fetchState;
28
28
  if (accountId != null) {
29
+ // Period bucket can be unhydrated during app-shell load.
29
30
  fetchState =
30
31
  accountReconciliationRecords[toMonthYearPeriodId(selectedPeriod)]
31
- .reconciliationByAccountID[accountId].transactionFetchState
32
+ ?.reconciliationByAccountID[accountId]?.transactionFetchState
32
33
  .fetchState;
33
34
  }
34
35
  else {
@@ -4,6 +4,10 @@ import { getClassById } from '../../../entity/class/classSelector';
4
4
  import { toProjectBasePayload, } from '../../../entity/project/projectPayload';
5
5
  import { getProjectById } from '../../../entity/project/projectSelector';
6
6
  import { getVendorByQboId, getVendorByVendorId, } from '../../../entity/vendor/vendorSelector';
7
+ const POSTING_TYPE_NAME = {
8
+ credit: 'Credit',
9
+ debit: 'Debit',
10
+ };
7
11
  const toRemitToAddressPayload = (address) => {
8
12
  if (address == null) {
9
13
  return undefined;
@@ -35,10 +39,12 @@ const toLinePayload = (state, line, transactionType) => {
35
39
  });
36
40
  }
37
41
  if (transactionType === 'journal_entry') {
38
- lineDetail.posting_type = line.postingType;
42
+ if (line.postingType != null) {
43
+ lineDetail.posting_type_name = POSTING_TYPE_NAME[line.postingType];
44
+ }
39
45
  const vendorQboId = toQboLineVendorId(state, line.vendorQboId);
40
46
  if (vendorQboId != null) {
41
- lineDetail.vendor = { qbo_id: vendorQboId };
47
+ lineDetail.vendor = { vendor_id: vendorQboId };
42
48
  }
43
49
  }
44
50
  return {
@@ -128,7 +134,6 @@ export const prepareCreateTransactionPayload = (state, localData) => {
128
134
  if (transactionType === 'journal_entry') {
129
135
  return {
130
136
  ...base,
131
- document_id: localData.documentId,
132
137
  lines,
133
138
  };
134
139
  }
@@ -29,9 +29,10 @@ const fetchReconciliationViewEpic = (actions$, state$, zeniAPI) => actions$.pipe
29
29
  }
30
30
  let fetchState;
31
31
  if (accountId != null) {
32
+ // Period bucket can be unhydrated during app-shell load.
32
33
  fetchState =
33
34
  accountReconciliationRecords[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]
34
- .reconciliationByAccountID[accountId].transactionFetchState
35
+ ?.reconciliationByAccountID[accountId]?.transactionFetchState
35
36
  .fetchState;
36
37
  }
37
38
  else {
@@ -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;
@@ -25,14 +25,15 @@ export interface CreateTransactionLineDetailPayload {
25
25
  qbo_id: ID;
26
26
  };
27
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.
28
+ * journal_entry only, inside line_detail. QBOJournalEntry reads only posting_type_name; a
29
+ * lowercase posting_type is dropped and QBO then rejects the line.
30
30
  */
31
- posting_type?: 'credit' | 'debit';
31
+ posting_type_name?: 'Credit' | 'Debit';
32
32
  /** Same shape the transaction update sends on a vendor line. */
33
33
  project?: ProjectBasePayload;
34
+ /** journal_entry only. The backend reads the QBO vendor id from `vendor_id`, not `qbo_id`. */
34
35
  vendor?: {
35
- qbo_id: ID;
36
+ vendor_id: ID;
36
37
  };
37
38
  }
38
39
  export interface CreateTransactionLinePayload {
@@ -51,8 +52,6 @@ export interface CreateTransactionRemitToAddressPayload {
51
52
  export interface CreateTransactionRequest extends Record<string, unknown> {
52
53
  transaction_date: string;
53
54
  transaction_type: string;
54
- /** journal_entry reference number. */
55
- document_id?: string;
56
55
  /** check / credit_card_credit reference number (QBO Purchase). */
57
56
  document_number?: string;
58
57
  from_account_id?: ID;
@@ -7,6 +7,10 @@ const classSelector_1 = require("../../../entity/class/classSelector");
7
7
  const projectPayload_1 = require("../../../entity/project/projectPayload");
8
8
  const projectSelector_1 = require("../../../entity/project/projectSelector");
9
9
  const vendorSelector_1 = require("../../../entity/vendor/vendorSelector");
10
+ const POSTING_TYPE_NAME = {
11
+ credit: 'Credit',
12
+ debit: 'Debit',
13
+ };
10
14
  const toRemitToAddressPayload = (address) => {
11
15
  if (address == null) {
12
16
  return undefined;
@@ -38,10 +42,12 @@ const toLinePayload = (state, line, transactionType) => {
38
42
  });
39
43
  }
40
44
  if (transactionType === 'journal_entry') {
41
- lineDetail.posting_type = line.postingType;
45
+ if (line.postingType != null) {
46
+ lineDetail.posting_type_name = POSTING_TYPE_NAME[line.postingType];
47
+ }
42
48
  const vendorQboId = toQboLineVendorId(state, line.vendorQboId);
43
49
  if (vendorQboId != null) {
44
- lineDetail.vendor = { qbo_id: vendorQboId };
50
+ lineDetail.vendor = { vendor_id: vendorQboId };
45
51
  }
46
52
  }
47
53
  return {
@@ -132,7 +138,6 @@ const prepareCreateTransactionPayload = (state, localData) => {
132
138
  if (transactionType === 'journal_entry') {
133
139
  return {
134
140
  ...base,
135
- document_id: localData.documentId,
136
141
  lines,
137
142
  };
138
143
  }
@@ -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.3.2",
3
+ "version": "5.3.3-beta0KB",
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",