@zeniai/client-epic-state 4.12.90 → 4.12.92

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.
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toSaveAccountMappingPayload = void 0;
4
4
  const toSaveAccountMappingPayload = (accountingLocalData) => {
5
5
  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
+ };
6
13
  const findAndUpdateAccount = (accountId, label, tax1099Config) => {
7
14
  const existingAccount = accounts.find((account) => account.account_id === accountId);
8
15
  if (existingAccount) {
@@ -29,30 +36,57 @@ const toSaveAccountMappingPayload = (accountingLocalData) => {
29
36
  if (accountingLocalData.selectedIncomeAccountId != null) {
30
37
  findAndUpdateAccount(accountingLocalData.selectedIncomeAccountId, 'uncategorized_income');
31
38
  }
39
+ else if (accountingLocalData.previousIncomeAccount) {
40
+ findAndUpdateAccount(accountingLocalData.previousIncomeAccount.accountId, '');
41
+ }
32
42
  if (accountingLocalData.selectedExpenseAccountId != null) {
33
43
  findAndUpdateAccount(accountingLocalData.selectedExpenseAccountId, 'uncategorized_expense');
34
44
  }
45
+ else if (accountingLocalData.previousExpenseAccount) {
46
+ findAndUpdateAccount(accountingLocalData.previousExpenseAccount.accountId, '');
47
+ }
35
48
  if (accountingLocalData.selectedBillPayAccountId != null) {
36
49
  findAndUpdateAccount(accountingLocalData.selectedBillPayAccountId, 'bank_charges_and_fees');
37
50
  }
51
+ else if (accountingLocalData.previousBillPayAccount) {
52
+ findAndUpdateAccount(accountingLocalData.previousBillPayAccount.accountId, '');
53
+ }
38
54
  if (accountingLocalData.selectedReimbursementsAccountId != null) {
39
55
  findAndUpdateAccount(accountingLocalData.selectedReimbursementsAccountId, 'travel_transportation');
40
56
  }
57
+ else if (accountingLocalData.previousReimbursementsAccount) {
58
+ findAndUpdateAccount(accountingLocalData.previousReimbursementsAccount.accountId, '');
59
+ }
41
60
  if (accountingLocalData.selectedPrepaidExpensesAccountIds.length > 0) {
42
61
  accountingLocalData.selectedPrepaidExpensesAccountIds.forEach((accountId) => {
43
62
  findAndUpdateAccount(accountId, 'prepaid_expenses');
44
63
  });
45
64
  }
65
+ else if (accountingLocalData.previousPrepaidExpensesAccount.length > 0) {
66
+ accountingLocalData.previousPrepaidExpensesAccount.forEach((account) => {
67
+ findAndUpdateAccount(account.accountId, '');
68
+ });
69
+ }
46
70
  if (accountingLocalData.selectedFixedAssetsAccountIds.length > 0) {
47
71
  accountingLocalData.selectedFixedAssetsAccountIds.forEach((accountId) => {
48
72
  findAndUpdateAccount(accountId, 'fixed_assets');
49
73
  });
50
74
  }
75
+ else if (accountingLocalData.previousFixedAssetsAccount.length > 0) {
76
+ accountingLocalData.previousFixedAssetsAccount.forEach((account) => {
77
+ findAndUpdateAccount(account.accountId, '');
78
+ });
79
+ }
51
80
  if (accountingLocalData.selectedAccruedExpensesAccountIds.length > 0) {
52
81
  accountingLocalData.selectedAccruedExpensesAccountIds.forEach((accountId) => {
53
82
  findAndUpdateAccount(accountId, 'accrued_expenses');
54
83
  });
55
84
  }
85
+ else if (accountingLocalData.previousAccruedExpensesAccount.length > 0) {
86
+ accountingLocalData.previousAccruedExpensesAccount.forEach((account) => {
87
+ findAndUpdateAccount(account.accountId, '');
88
+ });
89
+ }
56
90
  if (accountingLocalData.selectedBankAccounts1099FilingAccountIds.length > 0) {
57
91
  accountingLocalData.selectedBankAccounts1099FilingAccountIds.forEach((accountId) => {
58
92
  findAndUpdateAccount(accountId, '', {
@@ -64,6 +98,11 @@ const toSaveAccountMappingPayload = (accountingLocalData) => {
64
98
  });
65
99
  });
66
100
  }
101
+ else if (accountingLocalData.previousBankAccounts1099FilingAccount.length > 0) {
102
+ accountingLocalData.previousBankAccounts1099FilingAccount.forEach((account) => {
103
+ findAndUpdateAccount(account.accountId, '', initialTax1099Config);
104
+ });
105
+ }
67
106
  if (accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.length > 0) {
68
107
  accountingLocalData.selectedExpenseAccounts1099FilingAccountIds.forEach((account) => {
69
108
  findAndUpdateAccount(account.accountId, '', {
@@ -75,6 +114,11 @@ const toSaveAccountMappingPayload = (accountingLocalData) => {
75
114
  });
76
115
  });
77
116
  }
117
+ else if (accountingLocalData.previousExpenseAccounts1099FilingAccount.length > 0) {
118
+ accountingLocalData.previousExpenseAccounts1099FilingAccount.forEach((account) => {
119
+ findAndUpdateAccount(account.accountId, '', initialTax1099Config);
120
+ });
121
+ }
78
122
  return accounts;
79
123
  };
80
124
  exports.toSaveAccountMappingPayload = toSaveAccountMappingPayload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.12.90",
3
+ "version": "4.12.92",
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
  "types": "lib/index.d.ts",