@zeniai/client-epic-state 5.2.62-beta0ND → 5.2.62-beta1ND

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.
@@ -625,7 +625,7 @@ export const getDueDate = (billStageCode, dueDate, invoiceDate, bookCloseDate) =
625
625
  }
626
626
  };
627
627
  export const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId, lastSelectedFromAccount) => {
628
- const { paymentAccountState, depositAccountState, depositAccountListState, paymentAccountListState, } = state;
628
+ const { paymentAccountState, depositAccountState, paymentAccountListState } = state;
629
629
  if (fromAccountId != null) {
630
630
  const withdrawFromAsDepositAcc = getDepositAccountByDepositAccountId(depositAccountState, fromAccountId);
631
631
  const withdrawFromAsPaymentAcc = getPaymentAccountByPaymentAccountId(paymentAccountState, fromAccountId);
@@ -639,41 +639,15 @@ export const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId
639
639
  }
640
640
  }
641
641
  else {
642
- return getDefaultWithdrawFromAccount(state, depositAccountListState.accountIds, companyId ?? '', lastSelectedFromAccount);
642
+ return getDefaultWithdrawFromAccount(state, companyId ?? '', lastSelectedFromAccount);
643
643
  }
644
644
  return undefined;
645
645
  };
646
- export const getDefaultWithdrawFromAccount = (state, depositAccounts, companyId, lastSelectedFromAccount) => {
646
+ export const getDefaultWithdrawFromAccount = (state, companyId, lastSelectedFromAccount) => {
647
647
  const { depositAccountState, paymentAccountState, paymentAccountListState } = state;
648
648
  const companyView = getCompanyView(state, companyId, []);
649
649
  const primaryAccount = companyView?.company.company.companyBillPayInfo.primaryFundingAccount;
650
- let defaultAccount = undefined;
651
- // User paying bill for first time or previously paid with external account
652
- if (lastSelectedFromAccount == null ||
653
- lastSelectedFromAccount?.accountType === 'paymentAccount') {
654
- if (depositAccounts.length === 0) {
655
- defaultAccount = primaryAccount;
656
- }
657
- else {
658
- if (primaryAccount?.accountType === 'depositAccount') {
659
- defaultAccount = primaryAccount;
660
- }
661
- }
662
- }
663
- else {
664
- // User paid with Zeni account previously
665
- if (depositAccounts.length === 1) {
666
- defaultAccount = lastSelectedFromAccount;
667
- }
668
- else {
669
- if (primaryAccount?.accountType === 'depositAccount') {
670
- defaultAccount = primaryAccount;
671
- }
672
- else {
673
- defaultAccount = lastSelectedFromAccount;
674
- }
675
- }
676
- }
650
+ const defaultAccount = primaryAccount ?? lastSelectedFromAccount;
677
651
  if (defaultAccount != null) {
678
652
  const defaultAccAsDepositAcc = getDepositAccountByDepositAccountId(depositAccountState, defaultAccount?.accountId);
679
653
  const defaultAccAsPaymentAcc = getPaymentAccountByPaymentAccountId(paymentAccountState, defaultAccount?.accountId);
@@ -141,7 +141,7 @@ export declare const getWithdrawFrom: (state: RootState, fromAccountId?: ID, fro
141
141
  accountId: ID;
142
142
  accountType: AccountTypeSubConfigCodeKeyType;
143
143
  }) => FundingAccount | undefined;
144
- export declare const getDefaultWithdrawFromAccount: (state: RootState, depositAccounts: ID[], companyId: ID, lastSelectedFromAccount?: {
144
+ export declare const getDefaultWithdrawFromAccount: (state: RootState, companyId: ID, lastSelectedFromAccount?: {
145
145
  accountId: ID;
146
146
  accountType: AccountTypeSubConfigCodeKeyType;
147
147
  }) => FundingAccount | undefined;
@@ -640,7 +640,7 @@ const getDueDate = (billStageCode, dueDate, invoiceDate, bookCloseDate) => {
640
640
  };
641
641
  exports.getDueDate = getDueDate;
642
642
  const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId, lastSelectedFromAccount) => {
643
- const { paymentAccountState, depositAccountState, depositAccountListState, paymentAccountListState, } = state;
643
+ const { paymentAccountState, depositAccountState, paymentAccountListState } = state;
644
644
  if (fromAccountId != null) {
645
645
  const withdrawFromAsDepositAcc = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, fromAccountId);
646
646
  const withdrawFromAsPaymentAcc = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, fromAccountId);
@@ -654,42 +654,16 @@ const getWithdrawFrom = (state, fromAccountId, fromAccountType, companyId, lastS
654
654
  }
655
655
  }
656
656
  else {
657
- return (0, exports.getDefaultWithdrawFromAccount)(state, depositAccountListState.accountIds, companyId ?? '', lastSelectedFromAccount);
657
+ return (0, exports.getDefaultWithdrawFromAccount)(state, companyId ?? '', lastSelectedFromAccount);
658
658
  }
659
659
  return undefined;
660
660
  };
661
661
  exports.getWithdrawFrom = getWithdrawFrom;
662
- const getDefaultWithdrawFromAccount = (state, depositAccounts, companyId, lastSelectedFromAccount) => {
662
+ const getDefaultWithdrawFromAccount = (state, companyId, lastSelectedFromAccount) => {
663
663
  const { depositAccountState, paymentAccountState, paymentAccountListState } = state;
664
664
  const companyView = (0, getCompanyView_1.getCompanyView)(state, companyId, []);
665
665
  const primaryAccount = companyView?.company.company.companyBillPayInfo.primaryFundingAccount;
666
- let defaultAccount = undefined;
667
- // User paying bill for first time or previously paid with external account
668
- if (lastSelectedFromAccount == null ||
669
- lastSelectedFromAccount?.accountType === 'paymentAccount') {
670
- if (depositAccounts.length === 0) {
671
- defaultAccount = primaryAccount;
672
- }
673
- else {
674
- if (primaryAccount?.accountType === 'depositAccount') {
675
- defaultAccount = primaryAccount;
676
- }
677
- }
678
- }
679
- else {
680
- // User paid with Zeni account previously
681
- if (depositAccounts.length === 1) {
682
- defaultAccount = lastSelectedFromAccount;
683
- }
684
- else {
685
- if (primaryAccount?.accountType === 'depositAccount') {
686
- defaultAccount = primaryAccount;
687
- }
688
- else {
689
- defaultAccount = lastSelectedFromAccount;
690
- }
691
- }
692
- }
666
+ const defaultAccount = primaryAccount ?? lastSelectedFromAccount;
693
667
  if (defaultAccount != null) {
694
668
  const defaultAccAsDepositAcc = (0, depositAccountSelector_1.getDepositAccountByDepositAccountId)(depositAccountState, defaultAccount?.accountId);
695
669
  const defaultAccAsPaymentAcc = (0, paymentAccountSelector_1.getPaymentAccountByPaymentAccountId)(paymentAccountState, defaultAccount?.accountId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.62-beta0ND",
3
+ "version": "5.2.62-beta1ND",
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",