@zeniai/client-epic-state 4.13.12 → 4.13.13

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.
Files changed (43) hide show
  1. package/lib/entity/account/accountPayload.d.ts +1 -1
  2. package/lib/entity/tenant/clearAllEpic.d.ts +3 -1
  3. package/lib/entity/tenant/clearAllEpic.js +4 -0
  4. package/lib/entity/vendor/__mocks__/vendorMock.js +0 -2
  5. package/lib/entity/vendor/__mocks__/vendorStateMocks.d.ts +1 -0
  6. package/lib/entity/vendor/__mocks__/vendorStateMocks.js +73 -4
  7. package/lib/entity/vendor/vendorPayload.d.ts +6 -1
  8. package/lib/entity/vendor/vendorPayload.js +3 -3
  9. package/lib/entity/vendor/vendorState.d.ts +8 -1
  10. package/lib/entity/vendor/vendorType.d.ts +2 -0
  11. package/lib/entity/vendor/vendorType.js +4 -1
  12. package/lib/epic.d.ts +2 -1
  13. package/lib/epic.js +2 -1
  14. package/lib/reducer.d.ts +3 -0
  15. package/lib/reducer.js +3 -0
  16. package/lib/view/accountMappingView/__mocks__/accountMappingSelectorMock.d.ts +11 -0
  17. package/lib/view/accountMappingView/__mocks__/accountMappingSelectorMock.js +4607 -0
  18. package/lib/view/accountMappingView/accountMappingPayload.js +75 -32
  19. package/lib/view/accountMappingView/accountMappingReducer.js +36 -10
  20. package/lib/view/accountMappingView/accountMappingState.d.ts +1 -1
  21. package/lib/view/accountMappingView/accountMappingViewSelector.d.ts +5 -0
  22. package/lib/view/accountMappingView/accountMappingViewSelector.js +11 -1
  23. package/lib/view/accountMappingView/initializeAccountMappingViewEpic.d.ts +2 -1
  24. package/lib/view/accountMappingView/initializeAccountMappingViewEpic.js +2 -0
  25. package/lib/view/accountMappingView/saveAccountMappingViewEpic.js +6 -1
  26. package/lib/view/vendor1099TypeList/vendor1099TypeListEpic.d.ts +7 -0
  27. package/lib/view/vendor1099TypeList/vendor1099TypeListEpic.js +23 -0
  28. package/lib/view/vendor1099TypeList/vendor1099TypeListPayload.d.ts +15 -0
  29. package/lib/view/vendor1099TypeList/vendor1099TypeListPayload.js +2 -0
  30. package/lib/view/vendor1099TypeList/vendor1099TypeListReducer.d.ts +7 -0
  31. package/lib/view/vendor1099TypeList/vendor1099TypeListReducer.js +52 -0
  32. package/lib/view/vendor1099TypeList/vendor1099TypeListState.d.ts +9 -0
  33. package/lib/view/vendor1099TypeList/vendor1099TypeListState.js +2 -0
  34. package/lib/view/vendorFiling1099/__mock__/json/vendorFiling1099ListSuccess.json +4 -1
  35. package/lib/view/vendorFiling1099/__mock__/vendorFiling1099ListMock.js +12 -3
  36. package/lib/view/vendorFiling1099/__mock__/vendorFiling1099ListSelectorMock.js +2 -4
  37. package/lib/view/vendorFiling1099/__mock__/vendorFiling1099UploadDetailsMock.d.ts +4 -1
  38. package/lib/view/vendorFiling1099/vendorFiling1099List/fetchVendorsFiling1099AllEpic.d.ts +2 -2
  39. package/lib/view/vendorFiling1099/vendorFiling1099List/fetchVendorsFiling1099AllEpic.js +7 -7
  40. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListSelector.js +21 -10
  41. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListState.d.ts +1 -1
  42. package/lib/view/vendorFiling1099/vendorFiling1099List/vendorFiling1099ListState.js +1 -0
  43. package/package.json +1 -1
@@ -1,90 +1,99 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.toSaveAccountMappingPayload = void 0;
4
15
  const toSaveAccountMappingPayload = (accountingLocalData) => {
5
16
  const accounts = [];
6
- const initialTax1099Config = {
7
- is_bank_account: false,
8
- is_expense_account: false,
9
- expense_type: null,
10
- type_1099: null,
11
- box_type: null,
12
- };
13
17
  const findAndUpdateAccount = (accountId, label, tax1099Config) => {
14
18
  const existingAccount = accounts.find((account) => account.account_id === accountId);
15
19
  if (existingAccount) {
16
20
  // Add label if not already present
17
- if (label != '' &&
21
+ if (label !== '' &&
18
22
  existingAccount.labels &&
19
23
  !existingAccount.labels.includes(label)) {
20
24
  existingAccount.labels.push(label);
21
25
  }
22
26
  // Merge tax_1099_config fields, updating them if new values are non-null
23
27
  if (tax1099Config != null) {
24
- existingAccount.tax_1099_config = Object.assign(Object.assign({}, existingAccount.tax_1099_config), tax1099Config);
28
+ const { is_bank_account } = tax1099Config, restOfTax1099Config = __rest(tax1099Config, ["is_bank_account"]); // Exclude is_bank_account
29
+ existingAccount.tax_1099_config = Object.assign(Object.assign(Object.assign({}, existingAccount.tax_1099_config), restOfTax1099Config), { is_bank_account: existingAccount.tax_1099_config
30
+ ? existingAccount.tax_1099_config.is_bank_account
31
+ : is_bank_account });
25
32
  }
26
33
  }
27
34
  else {
28
35
  // Add a new account if it doesn't exist
29
- accounts.push({
30
- account_id: accountId,
31
- labels: label.length === 0 ? [] : [label],
32
- tax_1099_config: tax1099Config,
33
- });
36
+ if (accountId !== '') {
37
+ accounts.push({
38
+ account_id: accountId,
39
+ labels: label.length === 0 ? [] : [label],
40
+ tax_1099_config: tax1099Config,
41
+ });
42
+ }
34
43
  }
35
44
  };
36
45
  if (accountingLocalData.selectedIncomeAccountId != null) {
37
- findAndUpdateAccount(accountingLocalData.selectedIncomeAccountId, 'uncategorized_income');
46
+ findAndUpdateAccount(accountingLocalData.selectedIncomeAccountId, 'uncategorized_income', null);
38
47
  }
39
48
  else if (accountingLocalData.previousIncomeAccount) {
40
- findAndUpdateAccount(accountingLocalData.previousIncomeAccount.accountId, '');
49
+ findAndUpdateAccount(accountingLocalData.previousIncomeAccount.accountId, '', null);
41
50
  }
42
51
  if (accountingLocalData.selectedExpenseAccountId != null) {
43
- findAndUpdateAccount(accountingLocalData.selectedExpenseAccountId, 'uncategorized_expense');
52
+ findAndUpdateAccount(accountingLocalData.selectedExpenseAccountId, 'uncategorized_expense', null);
44
53
  }
45
54
  else if (accountingLocalData.previousExpenseAccount) {
46
- findAndUpdateAccount(accountingLocalData.previousExpenseAccount.accountId, '');
55
+ findAndUpdateAccount(accountingLocalData.previousExpenseAccount.accountId, '', null);
47
56
  }
48
57
  if (accountingLocalData.selectedBillPayAccountId != null) {
49
- findAndUpdateAccount(accountingLocalData.selectedBillPayAccountId, 'bank_charges_and_fees');
58
+ findAndUpdateAccount(accountingLocalData.selectedBillPayAccountId, 'bank_charges_and_fees', null);
50
59
  }
51
60
  else if (accountingLocalData.previousBillPayAccount) {
52
- findAndUpdateAccount(accountingLocalData.previousBillPayAccount.accountId, '');
61
+ findAndUpdateAccount(accountingLocalData.previousBillPayAccount.accountId, '', null);
53
62
  }
54
63
  if (accountingLocalData.selectedReimbursementsAccountId != null) {
55
- findAndUpdateAccount(accountingLocalData.selectedReimbursementsAccountId, 'travel_transportation');
64
+ findAndUpdateAccount(accountingLocalData.selectedReimbursementsAccountId, 'travel_transportation', null);
56
65
  }
57
66
  else if (accountingLocalData.previousReimbursementsAccount) {
58
- findAndUpdateAccount(accountingLocalData.previousReimbursementsAccount.accountId, '');
67
+ findAndUpdateAccount(accountingLocalData.previousReimbursementsAccount.accountId, '', null);
59
68
  }
60
69
  if (accountingLocalData.selectedPrepaidExpensesAccountIds.length > 0) {
61
70
  accountingLocalData.selectedPrepaidExpensesAccountIds.forEach((accountId) => {
62
- findAndUpdateAccount(accountId, 'prepaid_expenses');
71
+ findAndUpdateAccount(accountId, 'prepaid_expenses', null);
63
72
  });
64
73
  }
65
74
  else if (accountingLocalData.previousPrepaidExpensesAccount.length > 0) {
66
75
  accountingLocalData.previousPrepaidExpensesAccount.forEach((account) => {
67
- findAndUpdateAccount(account.accountId, '');
76
+ findAndUpdateAccount(account.accountId, '', null);
68
77
  });
69
78
  }
70
79
  if (accountingLocalData.selectedFixedAssetsAccountIds.length > 0) {
71
80
  accountingLocalData.selectedFixedAssetsAccountIds.forEach((accountId) => {
72
- findAndUpdateAccount(accountId, 'fixed_assets');
81
+ findAndUpdateAccount(accountId, 'fixed_assets', null);
73
82
  });
74
83
  }
75
84
  else if (accountingLocalData.previousFixedAssetsAccount.length > 0) {
76
85
  accountingLocalData.previousFixedAssetsAccount.forEach((account) => {
77
- findAndUpdateAccount(account.accountId, '');
86
+ findAndUpdateAccount(account.accountId, '', null);
78
87
  });
79
88
  }
80
89
  if (accountingLocalData.selectedAccruedExpensesAccountIds.length > 0) {
81
90
  accountingLocalData.selectedAccruedExpensesAccountIds.forEach((accountId) => {
82
- findAndUpdateAccount(accountId, 'accrued_expenses');
91
+ findAndUpdateAccount(accountId, 'accrued_expenses', null);
83
92
  });
84
93
  }
85
94
  else if (accountingLocalData.previousAccruedExpensesAccount.length > 0) {
86
95
  accountingLocalData.previousAccruedExpensesAccount.forEach((account) => {
87
- findAndUpdateAccount(account.accountId, '');
96
+ findAndUpdateAccount(account.accountId, '', null);
88
97
  });
89
98
  }
90
99
  if (accountingLocalData.selectedBankAccounts1099FilingAccountIds.length > 0) {
@@ -97,26 +106,60 @@ const toSaveAccountMappingPayload = (accountingLocalData) => {
97
106
  box_type: null,
98
107
  });
99
108
  });
109
+ const missingAccountIds = accountingLocalData.previousBankAccounts1099FilingAccount
110
+ .filter((account) => !accountingLocalData.selectedBankAccounts1099FilingAccountIds.includes(account.accountId))
111
+ .map((account) => account.accountId);
112
+ missingAccountIds.forEach((accountId) => {
113
+ findAndUpdateAccount(accountId, '', null);
114
+ });
100
115
  }
101
116
  else if (accountingLocalData.previousBankAccounts1099FilingAccount.length > 0) {
102
117
  accountingLocalData.previousBankAccounts1099FilingAccount.forEach((account) => {
103
- findAndUpdateAccount(account.accountId, '', initialTax1099Config);
118
+ findAndUpdateAccount(account.accountId, '', null);
104
119
  });
105
120
  }
106
- if (accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.length > 0) {
121
+ if (accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.length > 1) {
107
122
  accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.forEach((account) => {
108
123
  findAndUpdateAccount(account.accountId, '', {
109
- is_bank_account: false,
124
+ is_bank_account: accountingLocalData.selectedBankAccounts1099FilingAccountIds.includes(account.accountId),
110
125
  is_expense_account: true,
111
126
  expense_type: account.expenseType,
112
127
  type_1099: account.type1099,
113
128
  box_type: account.boxType,
114
129
  });
115
130
  });
131
+ const selectedAccountIds = accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.map((item) => item.accountId);
132
+ const missingAccountIds = accountingLocalData.previousExpenseAccounts1099FilingAccount
133
+ .filter((item) => !selectedAccountIds.includes(item.accountId))
134
+ .map((item) => item.accountId);
135
+ missingAccountIds.forEach((accountId) => {
136
+ findAndUpdateAccount(accountId, '', null);
137
+ });
138
+ }
139
+ else if (accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.length ===
140
+ 1 &&
141
+ accountingLocalData.selectedExpenseAccounts1099FilingAccountIds[0]
142
+ .accountId !== '') {
143
+ accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.forEach((account) => {
144
+ findAndUpdateAccount(account.accountId, '', {
145
+ is_bank_account: accountingLocalData.selectedBankAccounts1099FilingAccountIds.includes(account.accountId),
146
+ is_expense_account: true,
147
+ expense_type: account.expenseType,
148
+ type_1099: account.type1099,
149
+ box_type: account.boxType,
150
+ });
151
+ });
152
+ const selectedAccountIds = accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.map((item) => item.accountId);
153
+ const missingAccountIds = accountingLocalData.previousExpenseAccounts1099FilingAccount
154
+ .filter((item) => !selectedAccountIds.includes(item.accountId))
155
+ .map((item) => item.accountId);
156
+ missingAccountIds.forEach((accountId) => {
157
+ findAndUpdateAccount(accountId, '', null);
158
+ });
116
159
  }
117
160
  else if (accountingLocalData.previousExpenseAccounts1099FilingAccount.length > 0) {
118
161
  accountingLocalData.previousExpenseAccounts1099FilingAccount.forEach((account) => {
119
- findAndUpdateAccount(account.accountId, '', initialTax1099Config);
162
+ findAndUpdateAccount(account.accountId, '', null);
120
163
  });
121
164
  }
122
165
  return accounts;
@@ -181,7 +181,7 @@ const doUpdateAccountListForAccountTypes = (draft, accountPayloadList) => {
181
181
  else if (account.account_type === 'bank') {
182
182
  bankAccounts1099FilingList.push(account); // list for bank accounts for Filing 1099
183
183
  }
184
- expenseAccounts1099FilingList.push(account); // list for gl accounts
184
+ expenseAccounts1099FilingList.push(account); // list for expense Category 1099 accounts
185
185
  });
186
186
  draft.incomeAccountIdList = incomeList.map((account) => account.account_id);
187
187
  draft.expenseAccountIdList = expenseList.map((account) => account.account_id);
@@ -259,15 +259,41 @@ const doUpdateAccountListForAccountTypes = (draft, accountPayloadList) => {
259
259
  const expenseAccounts1099FilingAccountMetadata = expenseAccounts1099FilingList.map((acc) => (0, accountPayload_1.mapAccountMetadataPayloadToAccountMetadata)(acc));
260
260
  const expenseAccounts1099FilingAccountBase = expenseAccounts1099FilingList.map((acc) => (0, accountPayload_1.mapAccountBasePayloadToAccountBase)(acc));
261
261
  const expenseAccounts1099FilingAccountsIdentified = expenseAccounts1099FilingAccountBase.filter((account) => { var _a; return (_a = account.tax1099Config) === null || _a === void 0 ? void 0 : _a.isExpenseAccount; });
262
- draft.data = Object.assign(Object.assign({}, draft.data), { selectedExpenseAccounts1099FilingAccountIds: expenseAccounts1099FilingAccountsIdentified.map((account) => {
263
- var _a, _b, _c, _d, _e, _f;
264
- return ({
265
- accountId: account.accountId,
266
- expenseType: (_b = (_a = account.tax1099Config) === null || _a === void 0 ? void 0 : _a.expenseType1099) !== null && _b !== void 0 ? _b : '',
267
- type1099: (_d = (_c = account.tax1099Config) === null || _c === void 0 ? void 0 : _c.type1099) !== null && _d !== void 0 ? _d : '',
268
- boxType: (_f = (_e = account.tax1099Config) === null || _e === void 0 ? void 0 : _e.boxType) !== null && _f !== void 0 ? _f : '',
269
- });
270
- }), previousExpenseAccounts1099FilingAccount: expenseAccounts1099FilingAccountsIdentified });
262
+ draft.data = Object.assign(Object.assign({}, draft.data), { selectedExpenseAccounts1099FilingAccountIds: expenseAccounts1099FilingAccountsIdentified.length > 0
263
+ ? expenseAccounts1099FilingAccountsIdentified.map((account) => {
264
+ var _a, _b, _c, _d, _e, _f;
265
+ return ({
266
+ accountId: account.accountId,
267
+ expenseType: (_b = (_a = account.tax1099Config) === null || _a === void 0 ? void 0 : _a.expenseType1099) !== null && _b !== void 0 ? _b : '',
268
+ type1099: (_d = (_c = account.tax1099Config) === null || _c === void 0 ? void 0 : _c.type1099) !== null && _d !== void 0 ? _d : '',
269
+ boxType: (_f = (_e = account.tax1099Config) === null || _e === void 0 ? void 0 : _e.boxType) !== null && _f !== void 0 ? _f : '',
270
+ });
271
+ })
272
+ : [
273
+ {
274
+ accountId: '',
275
+ expenseType: '',
276
+ type1099: '',
277
+ boxType: '',
278
+ },
279
+ ], previousExpenseAccounts1099FilingAccount: expenseAccounts1099FilingAccountsIdentified.length > 0
280
+ ? expenseAccounts1099FilingAccountsIdentified.map((account) => {
281
+ var _a, _b, _c, _d, _e, _f;
282
+ return ({
283
+ accountId: account.accountId,
284
+ expenseType: (_b = (_a = account.tax1099Config) === null || _a === void 0 ? void 0 : _a.expenseType1099) !== null && _b !== void 0 ? _b : '',
285
+ type1099: (_d = (_c = account.tax1099Config) === null || _c === void 0 ? void 0 : _c.type1099) !== null && _d !== void 0 ? _d : '',
286
+ boxType: (_f = (_e = account.tax1099Config) === null || _e === void 0 ? void 0 : _e.boxType) !== null && _f !== void 0 ? _f : '',
287
+ });
288
+ })
289
+ : [
290
+ {
291
+ accountId: '',
292
+ expenseType: '',
293
+ type1099: '',
294
+ boxType: '',
295
+ },
296
+ ] });
271
297
  draft.expenseAccounts1099FilingNestedAccountListHierarchy =
272
298
  (0, getNestedAccountIDHierarchyForReport_1.geNestedAccountIDHierarchyForReport)(expenseAccounts1099FilingAccountMetadata);
273
299
  /* 1099 Mapping Section End */
@@ -24,7 +24,7 @@ export interface AccountMappingLocalData {
24
24
  previousFixedAssetsAccount: AccountBase[];
25
25
  previousAccruedExpensesAccount: AccountBase[];
26
26
  previousBankAccounts1099FilingAccount: AccountBase[];
27
- previousExpenseAccounts1099FilingAccount: AccountBase[];
27
+ previousExpenseAccounts1099FilingAccount: ExpenseCategory1099Filing[];
28
28
  }
29
29
  export interface ExpenseCategory1099Filing {
30
30
  accountId: ID;
@@ -5,6 +5,8 @@ import { AccountBase } from '../../entity/account/accountState';
5
5
  import { RootState } from '../../reducer';
6
6
  import { AccountMappingLocalData } from './accountMappingState';
7
7
  import { FetchStateAndError } from '../../commonStateTypes/common';
8
+ import { Expense1099Type } from '../vendor1099TypeList/vendor1099TypeListPayload';
9
+ import { VendorType } from '../vendorTypeList/vendorTypeListPayload';
8
10
  export interface AccountMappingView extends SelectorView {
9
11
  incomeAccountList: AccountBase[];
10
12
  expenseAccountList: AccountBase[];
@@ -15,6 +17,9 @@ export interface AccountMappingView extends SelectorView {
15
17
  accruedExpensesAccountList: AccountBase[];
16
18
  bankAccounts1099FilingAccountList: AccountBase[];
17
19
  expenseAccounts1099FilingAccountList: AccountBase[];
20
+ expenseTypeList: VendorType[];
21
+ expense1099TypeList: VendorType[];
22
+ boxTypesList: Expense1099Type;
18
23
  incomeRecommendation?: Recommendation;
19
24
  expenseRecommendation?: Recommendation;
20
25
  billPayRecommendation?: Recommendation;
@@ -4,7 +4,7 @@ exports.getAccountMappingView = void 0;
4
4
  const toolkit_1 = require("@reduxjs/toolkit");
5
5
  const accountSelector_1 = require("../../entity/account/accountSelector");
6
6
  const reduceFetchState_1 = require("../../commonStateTypes/reduceFetchState");
7
- exports.getAccountMappingView = (0, toolkit_1.createSelector)((state) => state.accountMappingState, (state) => state.accountState, (state) => state.tasksCardState, (accountMappingState, accountState, tasksCardState) => {
7
+ exports.getAccountMappingView = (0, toolkit_1.createSelector)((state) => state.accountMappingState, (state) => state.accountState, (state) => state.tasksCardState, (state) => state.vendor1099TypeListState, (accountMappingState, accountState, tasksCardState, vendor1099TypeListState) => {
8
8
  const incomeAccountList = [];
9
9
  accountMappingState.incomeAccountIdList.forEach((accountId) => {
10
10
  const account = (0, accountSelector_1.getAccountBase)(accountState, accountId, 'account_list_by_type');
@@ -68,9 +68,16 @@ exports.getAccountMappingView = (0, toolkit_1.createSelector)((state) => state.a
68
68
  expenseAccounts1099FilingAccountList.push(account);
69
69
  }
70
70
  });
71
+ const expenseTypeList = vendor1099TypeListState.expenseTypes;
72
+ const expense1099TypeList = vendor1099TypeListState.expense1099Types;
73
+ const boxTypesList = vendor1099TypeListState.boxTypes;
71
74
  const fetchState = (0, reduceFetchState_1.reduceAllFetchState)([
72
75
  accountMappingState.accountListFetchState,
73
76
  accountMappingState.recommendationFetchState,
77
+ {
78
+ fetchState: vendor1099TypeListState.fetchState,
79
+ error: vendor1099TypeListState.error,
80
+ },
74
81
  ]);
75
82
  const saveState = getSaveState(accountMappingState.updateFetchState, tasksCardState);
76
83
  return {
@@ -83,6 +90,9 @@ exports.getAccountMappingView = (0, toolkit_1.createSelector)((state) => state.a
83
90
  accruedExpensesAccountList,
84
91
  bankAccounts1099FilingAccountList,
85
92
  expenseAccounts1099FilingAccountList,
93
+ expenseTypeList,
94
+ expense1099TypeList,
95
+ boxTypesList,
86
96
  incomeRecommendation: accountMappingState.incomeRecommendations.length > 0
87
97
  ? accountMappingState.incomeRecommendations[0]
88
98
  : undefined,
@@ -1,6 +1,7 @@
1
1
  import { ActionsObservable } from 'redux-observable';
2
2
  import { fetchAccountListForAccountTypes, fetchRecommendationForAccountMapping } from './accountMappingReducer';
3
- export declare type ActionType = ReturnType<typeof fetchAccountListForAccountTypes> | ReturnType<typeof fetchRecommendationForAccountMapping>;
3
+ import { fetchVendor1099TypeList } from '../vendor1099TypeList/vendor1099TypeListReducer';
4
+ export declare type ActionType = ReturnType<typeof fetchAccountListForAccountTypes> | ReturnType<typeof fetchRecommendationForAccountMapping> | ReturnType<typeof fetchVendor1099TypeList>;
4
5
  export declare const initializeAccountMappingViewEpic: (actions$: ActionsObservable<ActionType>) => import("rxjs").Observable<{
5
6
  payload: undefined;
6
7
  type: string;
@@ -4,10 +4,12 @@ exports.initializeAccountMappingViewEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const accountMappingReducer_1 = require("./accountMappingReducer");
7
+ const vendor1099TypeListReducer_1 = require("../vendor1099TypeList/vendor1099TypeListReducer");
7
8
  const initializeAccountMappingViewEpic = (actions$) => actions$.pipe((0, operators_1.filter)(accountMappingReducer_1.initializeAccountMappingView.match), (0, operators_1.mergeMap)(() => {
8
9
  const fetchActions = [];
9
10
  fetchActions.push((0, accountMappingReducer_1.fetchAccountListForAccountTypes)());
10
11
  fetchActions.push((0, accountMappingReducer_1.fetchRecommendationForAccountMapping)());
12
+ fetchActions.push((0, vendor1099TypeListReducer_1.fetchVendor1099TypeList)());
11
13
  return (0, rxjs_1.from)(fetchActions);
12
14
  }));
13
15
  exports.initializeAccountMappingViewEpic = initializeAccountMappingViewEpic;
@@ -12,7 +12,12 @@ const saveAccountMappingViewEpic = (actions$, state, zeniAPI) => actions$.pipe((
12
12
  const accountMappingState = state.value.accountMappingState;
13
13
  const payload = (0, accountMappingPayload_1.toSaveAccountMappingPayload)(accountMappingState.data);
14
14
  if (payload.length === 0) {
15
- return (0, rxjs_1.from)([]);
15
+ const action = [
16
+ (0, accountMappingReducer_1.saveAccountMappingFailure)({
17
+ status: (0, responsePayload_1.createZeniAPIStatus)('No Account Mapping Data to Save'),
18
+ }),
19
+ ];
20
+ return (0, rxjs_1.from)(action);
16
21
  }
17
22
  else {
18
23
  return zeniAPI
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { ZeniAPI } from '../../zeniAPI';
4
+ import { RootState } from '../../reducer';
5
+ import { fetchVendor1099TypeList, updateVendor1099TypeList, updateVendor1099TypeListFailure } from './vendor1099TypeListReducer';
6
+ export declare type ActionType = ReturnType<typeof fetchVendor1099TypeList> | ReturnType<typeof updateVendor1099TypeList> | ReturnType<typeof updateVendor1099TypeListFailure>;
7
+ export declare const fetchVendor1099TypeListEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchVendor1099TypeListEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../responsePayload");
7
+ const vendor1099TypeListReducer_1 = require("./vendor1099TypeListReducer");
8
+ const fetchVendor1099TypeListEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(vendor1099TypeListReducer_1.fetchVendor1099TypeList.match), (0, operators_1.switchMap)(() => {
9
+ return zeniAPI
10
+ .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/1099-config`)
11
+ .pipe((0, operators_1.mergeMap)((response) => {
12
+ if ((0, responsePayload_1.isSuccessResponse)(response)) {
13
+ return (0, rxjs_1.of)((0, vendor1099TypeListReducer_1.updateVendor1099TypeList)(response));
14
+ }
15
+ else {
16
+ return (0, rxjs_1.of)((0, vendor1099TypeListReducer_1.updateVendor1099TypeListFailure)(response.status));
17
+ }
18
+ }), (0, operators_1.catchError)((error) => {
19
+ return (0, rxjs_1.of)((0, vendor1099TypeListReducer_1.updateVendor1099TypeListFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch vendor 1099 types REST API call errored out' +
20
+ JSON.stringify(error))));
21
+ }));
22
+ }));
23
+ exports.fetchVendor1099TypeListEpic = fetchVendor1099TypeListEpic;
@@ -0,0 +1,15 @@
1
+ import { ZeniAPIResponse } from '../../responsePayload';
2
+ import { VendorType } from '../vendorTypeList/vendorTypeListPayload';
3
+ export interface Expense1099Type {
4
+ int: VendorType[];
5
+ misc: VendorType[];
6
+ nec: VendorType[];
7
+ }
8
+ interface Vendor1099TypePayload {
9
+ vendor_types: VendorType[];
10
+ expense_types: VendorType[];
11
+ expense_1099_types: VendorType[];
12
+ expense_1099_box_type: Expense1099Type;
13
+ }
14
+ export declare type Vendor1099TypeListResponse = ZeniAPIResponse<Vendor1099TypePayload>;
15
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { ZeniAPIStatus } from '../../responsePayload';
2
+ import { Vendor1099TypeListResponse } from './vendor1099TypeListPayload';
3
+ import { Vendor1099TypeListState } from './vendor1099TypeListState';
4
+ export declare const initialState: Vendor1099TypeListState;
5
+ export declare const fetchVendor1099TypeList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, updateVendor1099TypeList: import("@reduxjs/toolkit").ActionCreatorWithPayload<Vendor1099TypeListResponse, string>, updateVendor1099TypeListFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, string>, clearVendor1099TypeList: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
6
+ declare const _default: import("@reduxjs/toolkit").Reducer<Vendor1099TypeListState, import("@reduxjs/toolkit").AnyAction>;
7
+ export default _default;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.clearVendor1099TypeList = exports.updateVendor1099TypeListFailure = exports.updateVendor1099TypeList = exports.fetchVendor1099TypeList = exports.initialState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ exports.initialState = {
7
+ fetchState: 'Not-Started',
8
+ error: undefined,
9
+ vendorTypes: [],
10
+ expenseTypes: [],
11
+ expense1099Types: [],
12
+ boxTypes: {
13
+ int: [],
14
+ misc: [],
15
+ nec: [],
16
+ },
17
+ hasValidState() {
18
+ return this.fetchState == 'Completed';
19
+ },
20
+ };
21
+ const vendor1099TypeList = (0, toolkit_1.createSlice)({
22
+ name: 'vendor1099TypeList',
23
+ initialState: exports.initialState,
24
+ reducers: {
25
+ fetchVendor1099TypeList(draft) {
26
+ draft.fetchState = 'In-Progress';
27
+ draft.error = undefined;
28
+ },
29
+ updateVendor1099TypeList(draft, action) {
30
+ var _a, _b, _c, _d, _e, _f, _g, _h;
31
+ draft.fetchState = 'Completed';
32
+ draft.error = undefined;
33
+ draft.vendorTypes = (_b = (_a = action.payload.data) === null || _a === void 0 ? void 0 : _a.vendor_types) !== null && _b !== void 0 ? _b : [];
34
+ draft.expenseTypes = (_d = (_c = action.payload.data) === null || _c === void 0 ? void 0 : _c.expense_types) !== null && _d !== void 0 ? _d : [];
35
+ draft.expense1099Types = (_f = (_e = action.payload.data) === null || _e === void 0 ? void 0 : _e.expense_1099_types) !== null && _f !== void 0 ? _f : [];
36
+ draft.boxTypes = (_h = (_g = action.payload.data) === null || _g === void 0 ? void 0 : _g.expense_1099_box_type) !== null && _h !== void 0 ? _h : {
37
+ int: [],
38
+ misc: [],
39
+ nec: [],
40
+ };
41
+ },
42
+ updateVendor1099TypeListFailure(draft, action) {
43
+ draft.fetchState = 'Error';
44
+ draft.error = action.payload;
45
+ },
46
+ clearVendor1099TypeList(draft) {
47
+ Object.assign(draft, exports.initialState);
48
+ },
49
+ },
50
+ });
51
+ _a = vendor1099TypeList.actions, exports.fetchVendor1099TypeList = _a.fetchVendor1099TypeList, exports.updateVendor1099TypeList = _a.updateVendor1099TypeList, exports.updateVendor1099TypeListFailure = _a.updateVendor1099TypeListFailure, exports.clearVendor1099TypeList = _a.clearVendor1099TypeList;
52
+ exports.default = vendor1099TypeList.reducer;
@@ -0,0 +1,9 @@
1
+ import { FetchedState } from '../../commonStateTypes/common';
2
+ import { VendorType } from '../vendorTypeList/vendorTypeListPayload';
3
+ import { Expense1099Type } from './vendor1099TypeListPayload';
4
+ export interface Vendor1099TypeListState extends FetchedState {
5
+ vendorTypes: VendorType[];
6
+ expenseTypes: VendorType[];
7
+ expense1099Types: VendorType[];
8
+ boxTypes: Expense1099Type;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -77,7 +77,10 @@
77
77
  "value": "550258131"
78
78
  },
79
79
  "vendor_1099_status": "incomplete",
80
- "vendor_1099_ytd_total": -2287.0,
80
+ "is_type_int": true,
81
+ "is_type_misc": false,
82
+ "is_type_nec": false,
83
+ "vendor_1099_ytd_total_nec": -2287.0,
81
84
  "w9_documents": []
82
85
  }
83
86
  ],
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.rootStateWithVendorFiling1099List = exports.vendorFiling1099ListFailureState = exports.vendorFiling1099ListSuccessState = exports.vendorFiling1099ListInProgressInitialState = exports.vendorFiling1099ListInProgressState = exports.vendorFiling1099ListFailureResponse = exports.vendorFiling1099ListSuccessResponse = exports.vendorFiling1099ListSelectorMock = void 0;
7
+ const zeniDayJS_1 = require("../../../zeniDayJS");
7
8
  const vendorFiling1099ListSuccess_json_1 = __importDefault(require("./json/vendorFiling1099ListSuccess.json"));
8
9
  const apiFailure_json_1 = __importDefault(require("../../../__testHelpers__/apiFailure.json"));
9
10
  const vendorFiling1099ListReducer_1 = require("../vendorFiling1099List/vendorFiling1099ListReducer");
10
11
  const vendorStateMocks_1 = require("../../../entity/vendor/__mocks__/vendorStateMocks");
11
12
  const reducer_1 = require("../../../reducer");
12
- const zeniDayJS_1 = require("../../../zeniDayJS");
13
+ const accountMappingSelectorMock_1 = require("../../accountMappingView/__mocks__/accountMappingSelectorMock");
13
14
  var vendorFiling1099ListSelectorMock_1 = require("./vendorFiling1099ListSelectorMock");
14
15
  Object.defineProperty(exports, "vendorFiling1099ListSelectorMock", { enumerable: true, get: function () { return vendorFiling1099ListSelectorMock_1.vendorFiling1099ListSelectorMock; } });
15
16
  exports.vendorFiling1099ListSuccessResponse = vendorFiling1099ListSuccess_json_1.default;
@@ -148,7 +149,7 @@ exports.vendorFiling1099ListFailureState = {
148
149
  exports.rootStateWithVendorFiling1099List = Object.assign({}, reducer_1.initialRootState, {
149
150
  vendorState: {
150
151
  vendorByID: {
151
- 'vendor_j12jh1g2g12jg3jh12:12': vendorStateMocks_1.vendorStateMock1,
152
+ 'vendor_j12jh1g2g12jg3jh12:12': vendorStateMocks_1.vendorStateMock7,
152
153
  },
153
154
  },
154
155
  vendorFiling1099ListState: {
@@ -183,7 +184,7 @@ exports.rootStateWithVendorFiling1099List = Object.assign({}, reducer_1.initialR
183
184
  },
184
185
  },
185
186
  },
186
- vendorTypeListState: {
187
+ vendor1099TypeListState: {
187
188
  fetchState: 'Completed',
188
189
  error: undefined,
189
190
  vendorTypes: [
@@ -196,5 +197,13 @@ exports.rootStateWithVendorFiling1099List = Object.assign({}, reducer_1.initialR
196
197
  name: 'Individual / Sole-Proprietor or Single-Member LLC',
197
198
  },
198
199
  ],
200
+ expenseTypes: [],
201
+ expense1099Types: [],
202
+ boxTypes: {
203
+ int: [],
204
+ misc: [],
205
+ nec: [],
206
+ },
199
207
  },
208
+ accountMappingState: accountMappingSelectorMock_1.accountMappingState,
200
209
  });
@@ -3,12 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vendorFiling1099ListSelectorMock = void 0;
4
4
  const vendorStateMocks_1 = require("../../../entity/vendor/__mocks__/vendorStateMocks");
5
5
  exports.vendorFiling1099ListSelectorMock = {
6
- fetchState: 'Not-Started',
6
+ fetchState: 'Completed',
7
7
  error: undefined,
8
8
  version: 0,
9
- vendors: [
10
- Object.assign({}, vendorStateMocks_1.vendorStateMock1),
11
- ],
9
+ vendors: [Object.assign({}, vendorStateMocks_1.vendorStateMock7)],
12
10
  lastRefreshSuccessTime: undefined,
13
11
  uiState: {
14
12
  sortKey: 'total',
@@ -78,7 +78,10 @@ export declare const vendorFiling1099UploadDetailsSuccessResponse: {
78
78
  value: string;
79
79
  };
80
80
  vendor_1099_status: string;
81
- vendor_1099_ytd_total: number;
81
+ is_type_int: boolean;
82
+ is_type_misc: boolean;
83
+ is_type_nec: boolean;
84
+ vendor_1099_ytd_total_nec: number;
82
85
  w9_documents: never[];
83
86
  }[];
84
87
  version: string;
@@ -2,7 +2,7 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
2
2
  import { Observable } from 'rxjs';
3
3
  import { RootState } from '../../../reducer';
4
4
  import { fetchVendorsFiling1099List } from './vendorFiling1099ListReducer';
5
- import { fetchVendorTypeList } from '../../vendorTypeList/vendorTypeListReducer';
5
+ import { fetchVendor1099TypeList } from '../../vendor1099TypeList/vendor1099TypeListReducer';
6
6
  import { initializeAccountMappingView } from '../../accountMappingView/accountMappingReducer';
7
- export declare type ActionType = ReturnType<typeof fetchVendorsFiling1099List> | ReturnType<typeof fetchVendorTypeList> | ReturnType<typeof initializeAccountMappingView>;
7
+ export declare type ActionType = ReturnType<typeof fetchVendorsFiling1099List> | ReturnType<typeof fetchVendor1099TypeList> | ReturnType<typeof initializeAccountMappingView>;
8
8
  export declare const fetchVendorsFiling1099AllEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -4,23 +4,23 @@ exports.fetchVendorsFiling1099AllEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const vendorFiling1099ListReducer_1 = require("./vendorFiling1099ListReducer");
7
- const vendorTypeListReducer_1 = require("../../vendorTypeList/vendorTypeListReducer");
7
+ const vendor1099TypeListReducer_1 = require("../../vendor1099TypeList/vendor1099TypeListReducer");
8
8
  const accountMappingReducer_1 = require("../../accountMappingView/accountMappingReducer");
9
9
  const fetchVendorsFiling1099AllEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(vendorFiling1099ListReducer_1.fetchVendorsFiling1099All.match), (0, operators_1.switchMap)((action) => {
10
10
  const state = state$.value;
11
11
  const vendorActions = [];
12
12
  if (action.payload.cacheOverride === true) {
13
- if (state.vendorTypeListState.hasValidState() === false &&
14
- state.vendorTypeListState.fetchState !== 'In-Progress') {
15
- vendorActions.push((0, vendorTypeListReducer_1.fetchVendorTypeList)());
13
+ if (state.vendor1099TypeListState.hasValidState() === false &&
14
+ state.vendor1099TypeListState.fetchState !== 'In-Progress') {
15
+ vendorActions.push((0, vendor1099TypeListReducer_1.fetchVendor1099TypeList)());
16
16
  }
17
17
  vendorActions.push((0, accountMappingReducer_1.initializeAccountMappingView)());
18
18
  vendorActions.push((0, vendorFiling1099ListReducer_1.fetchVendorsFiling1099List)());
19
19
  }
20
20
  else {
21
- if (state.vendorTypeListState.hasValidState() === false &&
22
- state.vendorTypeListState.fetchState !== 'In-Progress') {
23
- vendorActions.push((0, vendorTypeListReducer_1.fetchVendorTypeList)());
21
+ if (state.vendor1099TypeListState.hasValidState() === false &&
22
+ state.vendor1099TypeListState.fetchState !== 'In-Progress') {
23
+ vendorActions.push((0, vendor1099TypeListReducer_1.fetchVendor1099TypeList)());
24
24
  }
25
25
  vendorActions.push((0, accountMappingReducer_1.initializeAccountMappingView)());
26
26
  vendorActions.push((0, vendorFiling1099ListReducer_1.fetchVendorsFiling1099List)());