@zeniai/client-epic-state 5.0.84-betaAK1 → 5.0.84-betaAK2

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.
@@ -5,8 +5,8 @@ import { getAllFundingAccounts, mapDepositAccToFundingAccount, } from '../common
5
5
  import { getAllDepositAccounts } from '../zeniAccounts/depositAccountList/depositAccountListSelector';
6
6
  import { getAllPaymentAccounts } from '../zeniAccounts/paymentAccountList/paymentAccountListSelector';
7
7
  const buildCashManagementRule = (autoSweepFlowState, depositAccountState, treasuryDetailState) => {
8
- const { settingsId, bufferAmount, frequency, memo, primaryFundingAccountId } = autoSweepFlowState;
9
- if (settingsId == null) {
8
+ const { settingsId, bufferAmount, frequency, memo, primaryFundingAccountId, nextTransferDate } = autoSweepFlowState;
9
+ if (settingsId == null || primaryFundingAccountId == null) {
10
10
  return undefined;
11
11
  }
12
12
  const depositAccount = primaryFundingAccountId != null
@@ -21,6 +21,7 @@ const buildCashManagementRule = (autoSweepFlowState, depositAccountState, treasu
21
21
  ? mapDepositAccToFundingAccount(depositAccount)
22
22
  : undefined,
23
23
  treasurySummary: treasuryDetailState.accountSummary,
24
+ nextTransferDate,
24
25
  };
25
26
  };
26
27
  export const getAutoTransferRules = (state) => {
@@ -1,5 +1,6 @@
1
1
  import { toAmount } from '../../../../commonStateTypes/amount';
2
2
  import { getNextTransferDate } from '../../../../commonStateTypes/workingDayHelper';
3
+ import { date } from '../../../../zeniDayJS';
3
4
  import { toAutoSweepFrequency, } from './autoSweepFlowState';
4
5
  export const toSaveAutoSweepSettingsBody = (state) => ({
5
6
  first_run_date: getNextTransferDate(state.frequency).format('YYYY-MM-DD'),
@@ -21,6 +22,9 @@ export const toAutoSweepFlowStatePatch = (payload) => {
21
22
  return {
22
23
  bufferAmount: toAmount(payload.minimum_buffer_usd, currencyCode ?? 'USD', currencySymbol ?? '$'),
23
24
  frequency: toAutoSweepFrequency(payload.frequency) ?? 'weekly',
25
+ nextTransferDate: payload.next_transfer_date != null && payload.next_transfer_date !== ''
26
+ ? date(payload.next_transfer_date)
27
+ : undefined,
24
28
  primaryFundingAccountId: payload.source_bank_account.deposit_account_id ?? undefined,
25
29
  settingsId: payload.cash_management_settings_id ?? undefined,
26
30
  };
@@ -22,6 +22,7 @@ const autoSweepFlow = createSlice({
22
22
  const patch = toAutoSweepFlowStatePatch(action.payload.data);
23
23
  draft.bufferAmount = patch.bufferAmount;
24
24
  draft.frequency = patch.frequency;
25
+ draft.nextTransferDate = patch.nextTransferDate;
25
26
  draft.primaryFundingAccountId = patch.primaryFundingAccountId;
26
27
  draft.settingsId = patch.settingsId;
27
28
  draft.fetchState = 'Completed';
@@ -39,6 +39,7 @@ export const initialAutoSweepFlowState = {
39
39
  frequency: 'weekly',
40
40
  memo: '',
41
41
  saveStatus: { fetchState: 'Not-Started', error: undefined },
42
+ nextTransferDate: undefined,
42
43
  primaryFundingAccountId: undefined,
43
44
  settingsId: undefined,
44
45
  fetchState: 'Not-Started',
@@ -11,8 +11,8 @@ const setupViewSelector_1 = require("../commonSetup/setupViewSelector");
11
11
  const depositAccountListSelector_1 = require("../zeniAccounts/depositAccountList/depositAccountListSelector");
12
12
  const paymentAccountListSelector_1 = require("../zeniAccounts/paymentAccountList/paymentAccountListSelector");
13
13
  const buildCashManagementRule = (autoSweepFlowState, depositAccountState, treasuryDetailState) => {
14
- const { settingsId, bufferAmount, frequency, memo, primaryFundingAccountId } = autoSweepFlowState;
15
- if (settingsId == null) {
14
+ const { settingsId, bufferAmount, frequency, memo, primaryFundingAccountId, nextTransferDate } = autoSweepFlowState;
15
+ if (settingsId == null || primaryFundingAccountId == null) {
16
16
  return undefined;
17
17
  }
18
18
  const depositAccount = primaryFundingAccountId != null
@@ -27,6 +27,7 @@ const buildCashManagementRule = (autoSweepFlowState, depositAccountState, treasu
27
27
  ? (0, setupViewSelector_1.mapDepositAccToFundingAccount)(depositAccount)
28
28
  : undefined,
29
29
  treasurySummary: treasuryDetailState.accountSummary,
30
+ nextTransferDate,
30
31
  };
31
32
  };
32
33
  const getAutoTransferRules = (state) => {
@@ -45,6 +45,7 @@ export interface CashManagementRule {
45
45
  frequency: AutoSweepFrequency;
46
46
  memo: string;
47
47
  settingsId: ID;
48
+ nextTransferDate?: ZeniDate;
48
49
  primaryFundingAccount?: FundingAccount;
49
50
  treasurySummary?: TreasurySummaryWithBalance;
50
51
  }
@@ -2,6 +2,7 @@ import { Amount } from '../../../../commonStateTypes/amount';
2
2
  import { ID } from '../../../../commonStateTypes/common';
3
3
  import { DepositAccountPayload } from '../../../../entity/depositAccount/depositAccountPayload';
4
4
  import { ZeniAPIResponse } from '../../../../responsePayload';
5
+ import { ZeniDate } from '../../../../zeniDayJS';
5
6
  import { AutoSweepFlowState, AutoSweepFrequency } from './autoSweepFlowState';
6
7
  /**
7
8
  * Body sent to `PUT /cash-management/settings`. Field names match the
@@ -26,6 +27,7 @@ export interface CashManagementSettingsPayload {
26
27
  cash_management_settings_id: string | null;
27
28
  frequency: string;
28
29
  minimum_buffer_usd: number;
30
+ next_transfer_date: string;
29
31
  source_bank_account: DepositAccountPayload;
30
32
  }
31
33
  export type CashManagementSettingsResponse = ZeniAPIResponse<CashManagementSettingsPayload>;
@@ -40,6 +42,7 @@ export type CashManagementSettingsResponse = ZeniAPIResponse<CashManagementSetti
40
42
  export declare const toAutoSweepFlowStatePatch: (payload: CashManagementSettingsPayload) => {
41
43
  bufferAmount: Amount;
42
44
  frequency: AutoSweepFrequency;
45
+ nextTransferDate?: ZeniDate;
43
46
  primaryFundingAccountId?: ID;
44
47
  settingsId?: ID;
45
48
  };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toAutoSweepFlowStatePatch = exports.toSaveAutoSweepSettingsBody = void 0;
4
4
  const amount_1 = require("../../../../commonStateTypes/amount");
5
5
  const workingDayHelper_1 = require("../../../../commonStateTypes/workingDayHelper");
6
+ const zeniDayJS_1 = require("../../../../zeniDayJS");
6
7
  const autoSweepFlowState_1 = require("./autoSweepFlowState");
7
8
  const toSaveAutoSweepSettingsBody = (state) => ({
8
9
  first_run_date: (0, workingDayHelper_1.getNextTransferDate)(state.frequency).format('YYYY-MM-DD'),
@@ -25,6 +26,9 @@ const toAutoSweepFlowStatePatch = (payload) => {
25
26
  return {
26
27
  bufferAmount: (0, amount_1.toAmount)(payload.minimum_buffer_usd, currencyCode ?? 'USD', currencySymbol ?? '$'),
27
28
  frequency: (0, autoSweepFlowState_1.toAutoSweepFrequency)(payload.frequency) ?? 'weekly',
29
+ nextTransferDate: payload.next_transfer_date != null && payload.next_transfer_date !== ''
30
+ ? (0, zeniDayJS_1.date)(payload.next_transfer_date)
31
+ : undefined,
28
32
  primaryFundingAccountId: payload.source_bank_account.deposit_account_id ?? undefined,
29
33
  settingsId: payload.cash_management_settings_id ?? undefined,
30
34
  };
@@ -26,6 +26,7 @@ const autoSweepFlow = (0, toolkit_1.createSlice)({
26
26
  const patch = (0, autoSweepFlowPayload_1.toAutoSweepFlowStatePatch)(action.payload.data);
27
27
  draft.bufferAmount = patch.bufferAmount;
28
28
  draft.frequency = patch.frequency;
29
+ draft.nextTransferDate = patch.nextTransferDate;
29
30
  draft.primaryFundingAccountId = patch.primaryFundingAccountId;
30
31
  draft.settingsId = patch.settingsId;
31
32
  draft.fetchState = 'Completed';
@@ -1,5 +1,6 @@
1
1
  import { Amount } from '../../../../commonStateTypes/amount';
2
2
  import { FetchStateAndError, ID } from '../../../../commonStateTypes/common';
3
+ import { ZeniDate } from '../../../../zeniDayJS';
3
4
  /**
4
5
  * Cadence at which the auto-sweep transfer fires. Lowercase to match the
5
6
  * cash-management settings API contract (and the `SweepFrequency` literal
@@ -29,6 +30,7 @@ export interface AutoSweepFlowState extends FetchStateAndError {
29
30
  frequency: AutoSweepFrequency;
30
31
  memo: string;
31
32
  saveStatus: FetchStateAndError;
33
+ nextTransferDate?: ZeniDate;
32
34
  primaryFundingAccountId?: ID;
33
35
  settingsId?: ID;
34
36
  }
@@ -45,6 +45,7 @@ exports.initialAutoSweepFlowState = {
45
45
  frequency: 'weekly',
46
46
  memo: '',
47
47
  saveStatus: { fetchState: 'Not-Started', error: undefined },
48
+ nextTransferDate: undefined,
48
49
  primaryFundingAccountId: undefined,
49
50
  settingsId: undefined,
50
51
  fetchState: 'Not-Started',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.84-betaAK1",
3
+ "version": "5.0.84-betaAK2",
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",