@zeniai/client-epic-state 4.20.0-betaNB1 → 4.20.0
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.
- package/lib/commonStateTypes/animations.d.ts +1 -1
- package/lib/commonStateTypes/animations.js +0 -3
- package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
- package/lib/entity/snackbar/snackbarTypes.js +0 -5
- package/lib/epic.d.ts +1 -7
- package/lib/epic.js +1 -7
- package/lib/esm/commonStateTypes/animations.js +0 -3
- package/lib/esm/entity/snackbar/snackbarTypes.js +0 -5
- package/lib/esm/epic.js +1 -7
- package/lib/esm/index.js +0 -2
- package/lib/esm/reducer.js +0 -3
- package/lib/esm/view/spendManagement/treasury/treasuryList/epics/fetchTreasuryDetailEpic.js +2 -2
- package/lib/esm/view/spendManagement/treasury/treasuryList/treasuryDetailReducer.js +1 -2
- package/lib/index.d.ts +2 -6
- package/lib/index.js +1 -13
- package/lib/reducer.d.ts +0 -3
- package/lib/reducer.js +0 -3
- package/lib/tsconfig.typecheck.tsbuildinfo +1 -0
- package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +1 -1
- package/lib/view/spendManagement/treasury/treasuryList/epics/fetchTreasuryDetailEpic.js +2 -2
- package/lib/view/spendManagement/treasury/treasuryList/treasuryDetailReducer.d.ts +1 -2
- package/lib/view/spendManagement/treasury/treasuryList/treasuryDetailReducer.js +1 -2
- package/package.json +1 -1
- package/lib/esm/view/spendManagement/autotransferRules/autoTransferRulesPayload.js +0 -26
- package/lib/esm/view/spendManagement/autotransferRules/autoTransferRulesReducer.js +0 -199
- package/lib/esm/view/spendManagement/autotransferRules/autoTransferRulesSelector.js +0 -52
- package/lib/esm/view/spendManagement/autotransferRules/autoTransferRulesState.js +0 -1
- package/lib/esm/view/spendManagement/autotransferRules/epics/createAutoTransferRuleEpic.js +0 -91
- package/lib/esm/view/spendManagement/autotransferRules/epics/deleteAutoTransferRuleEpic.js +0 -48
- package/lib/esm/view/spendManagement/autotransferRules/epics/fetchAutoTransferReviewDetailEpic.js +0 -30
- package/lib/esm/view/spendManagement/autotransferRules/epics/fetchAutoTransferRuleHistory.js +0 -45
- package/lib/esm/view/spendManagement/autotransferRules/epics/fetchAutoTransferRulesEpic.js +0 -52
- package/lib/esm/view/spendManagement/autotransferRules/epics/updateAutoTransferRuleEpic.js +0 -69
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesPayload.d.ts +0 -75
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesPayload.js +0 -30
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesReducer.d.ts +0 -50
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesReducer.js +0 -206
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesSelector.d.ts +0 -24
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesSelector.js +0 -61
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesState.d.ts +0 -38
- package/lib/view/spendManagement/autotransferRules/autoTransferRulesState.js +0 -2
- package/lib/view/spendManagement/autotransferRules/epics/createAutoTransferRuleEpic.d.ts +0 -12
- package/lib/view/spendManagement/autotransferRules/epics/createAutoTransferRuleEpic.js +0 -97
- package/lib/view/spendManagement/autotransferRules/epics/deleteAutoTransferRuleEpic.d.ts +0 -8
- package/lib/view/spendManagement/autotransferRules/epics/deleteAutoTransferRuleEpic.js +0 -52
- package/lib/view/spendManagement/autotransferRules/epics/fetchAutoTransferReviewDetailEpic.d.ts +0 -7
- package/lib/view/spendManagement/autotransferRules/epics/fetchAutoTransferReviewDetailEpic.js +0 -34
- package/lib/view/spendManagement/autotransferRules/epics/fetchAutoTransferRuleHistory.d.ts +0 -7
- package/lib/view/spendManagement/autotransferRules/epics/fetchAutoTransferRuleHistory.js +0 -52
- package/lib/view/spendManagement/autotransferRules/epics/fetchAutoTransferRulesEpic.d.ts +0 -10
- package/lib/view/spendManagement/autotransferRules/epics/fetchAutoTransferRulesEpic.js +0 -56
- package/lib/view/spendManagement/autotransferRules/epics/updateAutoTransferRuleEpic.d.ts +0 -8
- package/lib/view/spendManagement/autotransferRules/epics/updateAutoTransferRuleEpic.js +0 -73
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
2
|
-
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
|
|
5
|
-
import { mapPayloadToAutoTransferRule, } from '../autoTransferRulesPayload';
|
|
6
|
-
import { updateAutoTransferRule, updateAutoTransferRuleFailure, updateAutoTransferRuleSuccess, } from '../autoTransferRulesReducer';
|
|
7
|
-
import { mapAutoTransferRuleLocalDataToPayload } from './createAutoTransferRuleEpic';
|
|
8
|
-
export const updateAutoTransferRuleEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(updateAutoTransferRule.match), switchMap((action) => {
|
|
9
|
-
const { ruleId, pauseRule, resumeRule } = action.payload;
|
|
10
|
-
const requestBody = mapAutoTransferRuleLocalDataToPayload(state$.value.autotransferRulesState.ruleUpdateLocalData, pauseRule, resumeRule);
|
|
11
|
-
return zeniAPI
|
|
12
|
-
.putAndGetJSON(`${zeniAPI.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/${ruleId}`, requestBody)
|
|
13
|
-
.pipe(mergeMap((response) => {
|
|
14
|
-
if (isSuccessResponse(response) && response.data != null) {
|
|
15
|
-
const rule = mapPayloadToAutoTransferRule(response.data.auto_transfer_rule);
|
|
16
|
-
const isPauseOrResumeOnly = Object.keys(requestBody).length === 1 &&
|
|
17
|
-
'is_active' in requestBody;
|
|
18
|
-
const messageSection = isPauseOrResumeOnly
|
|
19
|
-
? requestBody.is_active === false
|
|
20
|
-
? 'auto_transfer_rule_pause'
|
|
21
|
-
: 'auto_transfer_rule_resume'
|
|
22
|
-
: 'auto_transfer_rule_update';
|
|
23
|
-
const actions = [
|
|
24
|
-
updateAutoTransferRuleSuccess({ rule }),
|
|
25
|
-
openSnackbar({
|
|
26
|
-
messageSection,
|
|
27
|
-
messageText: 'success',
|
|
28
|
-
type: 'success',
|
|
29
|
-
variables: [
|
|
30
|
-
{
|
|
31
|
-
variableName: '__ruleName__',
|
|
32
|
-
variableValue: rule.ruleType === 'minimum_balance'
|
|
33
|
-
? 'Maintain a Minimum Balance'
|
|
34
|
-
: rule.ruleType === 'recurring'
|
|
35
|
-
? 'Make a Recurring Transfer'
|
|
36
|
-
: 'Distribute Balance by Percentage',
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
}),
|
|
40
|
-
];
|
|
41
|
-
return from(actions);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
return from([
|
|
45
|
-
updateAutoTransferRuleFailure({
|
|
46
|
-
ruleId,
|
|
47
|
-
fetchState: 'Error',
|
|
48
|
-
error: response.status,
|
|
49
|
-
}),
|
|
50
|
-
openSnackbar({
|
|
51
|
-
messageSection: 'auto_transfer_rule_update',
|
|
52
|
-
messageText: 'failed',
|
|
53
|
-
type: 'error',
|
|
54
|
-
variables: [
|
|
55
|
-
{
|
|
56
|
-
variableName: '_api-error_',
|
|
57
|
-
variableValue: response.status.message,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
}),
|
|
61
|
-
]);
|
|
62
|
-
}
|
|
63
|
-
}), catchError((error) => of(updateAutoTransferRuleFailure({
|
|
64
|
-
ruleId,
|
|
65
|
-
fetchState: 'Error',
|
|
66
|
-
error: createZeniAPIStatus('Unexpected Error', 'Update auto transfer rule REST API call errored out ' +
|
|
67
|
-
JSON.stringify(error)),
|
|
68
|
-
}))));
|
|
69
|
-
}));
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Amount } from '../../../commonStateTypes/amount';
|
|
2
|
-
import { ZeniAPIResponse } from '../../../responsePayload';
|
|
3
|
-
import { ZeniDate } from '../../../zeniDayJS';
|
|
4
|
-
import { FundingAccount } from '../commonSetup/setupViewSelector';
|
|
5
|
-
import { TreasuryAccount } from '../treasury/treasuryTransferMoney/treasuryTransferMoneyState';
|
|
6
|
-
import { AutoTransferRule } from './autoTransferRulesState';
|
|
7
|
-
export type AutoTransferRuleType = 'minimum_balance' | 'recurring' | 'percentage_of_balance';
|
|
8
|
-
export type AutoTransferRuleFrequency = 'daily' | 'weekly' | 'monthly';
|
|
9
|
-
export interface DestinationBankAccountMetadataPayload {
|
|
10
|
-
account_id: string;
|
|
11
|
-
account_type: string;
|
|
12
|
-
percentage: number;
|
|
13
|
-
}
|
|
14
|
-
export interface AutoTransferRulePayload {
|
|
15
|
-
amount: number;
|
|
16
|
-
auto_transfer_rule_id: string;
|
|
17
|
-
create_time: string;
|
|
18
|
-
created_by_user_id: string;
|
|
19
|
-
currency_code: string;
|
|
20
|
-
currency_symbol: string;
|
|
21
|
-
destination_bank_account_id: string | null;
|
|
22
|
-
destination_bank_account_metadata: DestinationBankAccountMetadataPayload[] | null;
|
|
23
|
-
destination_bank_account_type: string;
|
|
24
|
-
frequency: AutoTransferRuleFrequency;
|
|
25
|
-
is_active: boolean;
|
|
26
|
-
is_deleted: boolean;
|
|
27
|
-
last_run_time: string | null;
|
|
28
|
-
last_run_transaction_metadata: unknown | null;
|
|
29
|
-
next_transfer_date: string;
|
|
30
|
-
rule_type: AutoTransferRuleType;
|
|
31
|
-
source_bank_account_id: string;
|
|
32
|
-
source_bank_account_type: string;
|
|
33
|
-
update_time: string;
|
|
34
|
-
}
|
|
35
|
-
interface AutoTransferRulesPayload {
|
|
36
|
-
auto_transfer_rules: AutoTransferRulePayload[];
|
|
37
|
-
}
|
|
38
|
-
export type FetchAutoTransferRulesResponse = ZeniAPIResponse<AutoTransferRulesPayload>;
|
|
39
|
-
export interface AutoTransferRuleRequestBody {
|
|
40
|
-
amount?: number;
|
|
41
|
-
currency_code?: string;
|
|
42
|
-
currency_symbol?: string;
|
|
43
|
-
destination_bank_account_id?: string;
|
|
44
|
-
destination_bank_account_metadata?: DestinationBankAccountMetadataPayload[];
|
|
45
|
-
destination_bank_account_type?: string;
|
|
46
|
-
first_transfer_date?: string;
|
|
47
|
-
frequency?: AutoTransferRuleFrequency;
|
|
48
|
-
is_active?: boolean;
|
|
49
|
-
next_transfer_date?: string;
|
|
50
|
-
rule_type?: AutoTransferRuleType;
|
|
51
|
-
source_bank_account_id?: string;
|
|
52
|
-
source_bank_account_type?: string;
|
|
53
|
-
}
|
|
54
|
-
export interface AutoTransferRuleLocalData {
|
|
55
|
-
amount?: Amount;
|
|
56
|
-
destinationAccount?: FundingAccount | TreasuryAccount;
|
|
57
|
-
destinationAccountWithPercentAllocation?: {
|
|
58
|
-
account: FundingAccount | TreasuryAccount;
|
|
59
|
-
percentage: number;
|
|
60
|
-
}[];
|
|
61
|
-
firstTransferDate?: ZeniDate;
|
|
62
|
-
frequency?: AutoTransferRuleFrequency;
|
|
63
|
-
ruleType?: AutoTransferRuleType;
|
|
64
|
-
sourceAccount?: FundingAccount | TreasuryAccount;
|
|
65
|
-
}
|
|
66
|
-
interface CreateAutoTransferRulesPayload {
|
|
67
|
-
auto_transfer_rule: AutoTransferRulePayload;
|
|
68
|
-
}
|
|
69
|
-
export type CreateAutoTransferRulesResponse = ZeniAPIResponse<CreateAutoTransferRulesPayload>;
|
|
70
|
-
interface DeleteAutoTransferRulePayload {
|
|
71
|
-
message: string;
|
|
72
|
-
}
|
|
73
|
-
export type DeleteAutoTransferRuleResponse = ZeniAPIResponse<DeleteAutoTransferRulePayload>;
|
|
74
|
-
export declare const mapPayloadToAutoTransferRule: (payload: AutoTransferRulePayload) => AutoTransferRule;
|
|
75
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mapPayloadToAutoTransferRule = void 0;
|
|
4
|
-
const zeniDayJS_1 = require("../../../zeniDayJS");
|
|
5
|
-
const mapPayloadToAutoTransferRule = (payload) => ({
|
|
6
|
-
amount: payload.amount,
|
|
7
|
-
autoTransferRuleId: payload.auto_transfer_rule_id,
|
|
8
|
-
createTime: payload.create_time != null ? (0, zeniDayJS_1.date)(payload.create_time) : undefined,
|
|
9
|
-
currencyCode: payload.currency_code,
|
|
10
|
-
currencySymbol: payload.currency_symbol ?? '$',
|
|
11
|
-
destinationBankAccountId: payload.destination_bank_account_id,
|
|
12
|
-
destinationBankAccountMetadata: payload.destination_bank_account_metadata?.map((m) => ({
|
|
13
|
-
accountId: m.account_id,
|
|
14
|
-
accountType: m.account_type,
|
|
15
|
-
percentage: m.percentage,
|
|
16
|
-
})) ?? undefined,
|
|
17
|
-
destinationBankAccountType: payload.destination_bank_account_type ?? undefined,
|
|
18
|
-
frequency: payload.frequency,
|
|
19
|
-
isActive: payload.is_active,
|
|
20
|
-
isDeleted: payload.is_deleted,
|
|
21
|
-
lastRunTime: payload.last_run_time,
|
|
22
|
-
nextTransferDate: payload.next_transfer_date != null
|
|
23
|
-
? (0, zeniDayJS_1.date)(payload.next_transfer_date)
|
|
24
|
-
: undefined,
|
|
25
|
-
ruleType: payload.rule_type,
|
|
26
|
-
sourceBankAccountId: payload.source_bank_account_id,
|
|
27
|
-
sourceBankAccountType: payload.source_bank_account_type,
|
|
28
|
-
updateTime: payload.update_time != null ? (0, zeniDayJS_1.date)(payload.update_time) : undefined,
|
|
29
|
-
});
|
|
30
|
-
exports.mapPayloadToAutoTransferRule = mapPayloadToAutoTransferRule;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { FetchState, ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import { ZeniAPIStatus } from '../../../responsePayload';
|
|
3
|
-
import { HistoricEventPayload } from '../commonHistoryView/commonHistoryPayload';
|
|
4
|
-
import { ReviewTransferMoneyPayload } from '../zeniAccounts/transferDetail/transferDetailPayload';
|
|
5
|
-
import { AutoTransferRuleLocalData } from './autoTransferRulesPayload';
|
|
6
|
-
import { AutoTransferRule, AutoTransferRulesState } from './autoTransferRulesState';
|
|
7
|
-
export declare const initialState: AutoTransferRulesState;
|
|
8
|
-
export declare const fetchAutoTransferRules: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any], {
|
|
9
|
-
cacheOverride: any;
|
|
10
|
-
}, "autotransferRules/fetchAutoTransferRules", never, never>, updateAutoTransferRules: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
11
|
-
rules: AutoTransferRule[];
|
|
12
|
-
}, "autotransferRules/updateAutoTransferRules">, updateAutoTransferRulesFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
13
|
-
fetchState: FetchState;
|
|
14
|
-
error?: ZeniAPIStatus;
|
|
15
|
-
}, "autotransferRules/updateAutoTransferRulesFailure">, fetchAutoTransferReviewDetail: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"autotransferRules/fetchAutoTransferReviewDetail">, updateAutoTransferReviewDetail: import("@reduxjs/toolkit").ActionCreatorWithPayload<ReviewTransferMoneyPayload, "autotransferRules/updateAutoTransferReviewDetail">, updateAutoTransferReviewDetailFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "autotransferRules/updateAutoTransferReviewDetailFailure">, clearAutoTransferReviewDetail: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"autotransferRules/clearAutoTransferReviewDetail">, createAutoTransferRule: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"autotransferRules/createAutoTransferRule">, createAutoTransferRuleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
16
|
-
rule: AutoTransferRule;
|
|
17
|
-
}, "autotransferRules/createAutoTransferRuleSuccess">, createAutoTransferRuleFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
18
|
-
fetchState: FetchState;
|
|
19
|
-
error?: ZeniAPIStatus;
|
|
20
|
-
}, "autotransferRules/createAutoTransferRuleFailure">, updateAutoTransferRule: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ruleId: string, pauseRule?: boolean | undefined, resumeRule?: boolean | undefined], {
|
|
21
|
-
ruleId: string;
|
|
22
|
-
pauseRule: boolean | undefined;
|
|
23
|
-
resumeRule: boolean | undefined;
|
|
24
|
-
}, "autotransferRules/updateAutoTransferRule", never, never>, updateAutoTransferRuleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
25
|
-
rule: AutoTransferRule;
|
|
26
|
-
}, "autotransferRules/updateAutoTransferRuleSuccess">, updateAutoTransferRuleFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
27
|
-
fetchState: FetchState;
|
|
28
|
-
ruleId: ID;
|
|
29
|
-
error?: ZeniAPIStatus;
|
|
30
|
-
}, "autotransferRules/updateAutoTransferRuleFailure">, deleteAutoTransferRule: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ruleId: string], {
|
|
31
|
-
ruleId: string;
|
|
32
|
-
}, "autotransferRules/deleteAutoTransferRule", never, never>, deleteAutoTransferRuleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
33
|
-
ruleId: ID;
|
|
34
|
-
}, "autotransferRules/deleteAutoTransferRuleSuccess">, deleteAutoTransferRuleFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
35
|
-
fetchState: FetchState;
|
|
36
|
-
ruleId: ID;
|
|
37
|
-
error?: ZeniAPIStatus;
|
|
38
|
-
}, "autotransferRules/deleteAutoTransferRuleFailure">, fetchAutoTransferRuleHistory: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ruleId: string, cacheOverride?: any], {
|
|
39
|
-
ruleId: string;
|
|
40
|
-
cacheOverride: any;
|
|
41
|
-
}, "autotransferRules/fetchAutoTransferRuleHistory", never, never>, updateAutoTransferRuleHistory: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
42
|
-
historicEventsPayload: HistoricEventPayload[];
|
|
43
|
-
ruleId: ID;
|
|
44
|
-
}, "autotransferRules/updateAutoTransferRuleHistory">, updateAutoTransferRuleHistoryFetchStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
45
|
-
fetchState: FetchState;
|
|
46
|
-
ruleId: ID;
|
|
47
|
-
error?: ZeniAPIStatus;
|
|
48
|
-
}, "autotransferRules/updateAutoTransferRuleHistoryFetchStatus">, updateRuleLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<AutoTransferRuleLocalData, "autotransferRules/updateRuleLocalData">, clearRuleUpdateLocalData: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"autotransferRules/clearRuleUpdateLocalData">, clearAutoTransferRules: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"autotransferRules/clearAutoTransferRules">;
|
|
49
|
-
declare const _default: import("redux").Reducer<AutoTransferRulesState>;
|
|
50
|
-
export default _default;
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a;
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.clearAutoTransferRules = exports.clearRuleUpdateLocalData = exports.updateRuleLocalData = exports.updateAutoTransferRuleHistoryFetchStatus = exports.updateAutoTransferRuleHistory = exports.fetchAutoTransferRuleHistory = exports.deleteAutoTransferRuleFailure = exports.deleteAutoTransferRuleSuccess = exports.deleteAutoTransferRule = exports.updateAutoTransferRuleFailure = exports.updateAutoTransferRuleSuccess = exports.updateAutoTransferRule = exports.createAutoTransferRuleFailure = exports.createAutoTransferRuleSuccess = exports.createAutoTransferRule = exports.clearAutoTransferReviewDetail = exports.updateAutoTransferReviewDetailFailure = exports.updateAutoTransferReviewDetail = exports.fetchAutoTransferReviewDetail = exports.updateAutoTransferRulesFailure = exports.updateAutoTransferRules = exports.fetchAutoTransferRules = exports.initialState = void 0;
|
|
8
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
9
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
-
const commonHistory_1 = require("../commonHistoryView/commonHistory");
|
|
11
|
-
const commonHistoryPayload_1 = require("../commonHistoryView/commonHistoryPayload");
|
|
12
|
-
const transferDetailPayload_1 = require("../zeniAccounts/transferDetail/transferDetailPayload");
|
|
13
|
-
exports.initialState = {
|
|
14
|
-
autoTransferReviewDetail: {
|
|
15
|
-
reviewTransferMoney: {
|
|
16
|
-
isShowDailyAchLimitWarning: false,
|
|
17
|
-
dailyAchDebitLimit: {
|
|
18
|
-
amount: 0,
|
|
19
|
-
currencyCode: 'USD',
|
|
20
|
-
currencySymbol: '$',
|
|
21
|
-
},
|
|
22
|
-
transferSchedules: [],
|
|
23
|
-
},
|
|
24
|
-
fetchState: 'Not-Started',
|
|
25
|
-
error: undefined,
|
|
26
|
-
},
|
|
27
|
-
historyByRuleId: {},
|
|
28
|
-
ruleDeleteStatusById: {},
|
|
29
|
-
ruleUpdateLocalData: {},
|
|
30
|
-
ruleUpdateStatusById: {},
|
|
31
|
-
rules: [],
|
|
32
|
-
fetchState: 'Not-Started',
|
|
33
|
-
error: undefined,
|
|
34
|
-
createRuleFetchState: {
|
|
35
|
-
fetchState: 'Not-Started',
|
|
36
|
-
error: undefined,
|
|
37
|
-
},
|
|
38
|
-
hasValidState() {
|
|
39
|
-
return this.fetchState === 'Completed';
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
const autotransferRules = (0, toolkit_1.createSlice)({
|
|
43
|
-
name: 'autotransferRules',
|
|
44
|
-
initialState: exports.initialState,
|
|
45
|
-
reducers: {
|
|
46
|
-
fetchAutoTransferRules: {
|
|
47
|
-
reducer(draft) {
|
|
48
|
-
draft.fetchState = 'In-Progress';
|
|
49
|
-
},
|
|
50
|
-
prepare(cacheOverride = false) {
|
|
51
|
-
return {
|
|
52
|
-
payload: {
|
|
53
|
-
cacheOverride,
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
updateAutoTransferRules(draft, action) {
|
|
59
|
-
draft.rules = action.payload.rules;
|
|
60
|
-
draft.fetchState = 'Completed';
|
|
61
|
-
draft.error = undefined;
|
|
62
|
-
},
|
|
63
|
-
updateAutoTransferRulesFailure(draft, action) {
|
|
64
|
-
draft.fetchState = action.payload.fetchState;
|
|
65
|
-
draft.error = action.payload.error;
|
|
66
|
-
},
|
|
67
|
-
updateRuleLocalData(draft, action) {
|
|
68
|
-
draft.ruleUpdateLocalData = {
|
|
69
|
-
...draft.ruleUpdateLocalData,
|
|
70
|
-
...action.payload,
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
clearRuleUpdateLocalData(draft) {
|
|
74
|
-
draft.ruleUpdateLocalData = {};
|
|
75
|
-
},
|
|
76
|
-
fetchAutoTransferReviewDetail(draft) {
|
|
77
|
-
draft.autoTransferReviewDetail.fetchState = 'In-Progress';
|
|
78
|
-
draft.autoTransferReviewDetail.error = undefined;
|
|
79
|
-
},
|
|
80
|
-
updateAutoTransferReviewDetail(draft, action) {
|
|
81
|
-
draft.autoTransferReviewDetail.fetchState = 'Completed';
|
|
82
|
-
draft.autoTransferReviewDetail.error = undefined;
|
|
83
|
-
draft.autoTransferReviewDetail.reviewTransferMoney =
|
|
84
|
-
(0, transferDetailPayload_1.mapReviewTransferMoneyPayloadToReviewTransferMoney)(action.payload);
|
|
85
|
-
},
|
|
86
|
-
updateAutoTransferReviewDetailFailure(draft, action) {
|
|
87
|
-
draft.autoTransferReviewDetail.fetchState = 'Error';
|
|
88
|
-
draft.autoTransferReviewDetail.error = action.payload;
|
|
89
|
-
},
|
|
90
|
-
clearAutoTransferReviewDetail(draft) {
|
|
91
|
-
draft.autoTransferReviewDetail = exports.initialState.autoTransferReviewDetail;
|
|
92
|
-
},
|
|
93
|
-
createAutoTransferRule(draft) {
|
|
94
|
-
draft.createRuleFetchState = {
|
|
95
|
-
fetchState: 'In-Progress',
|
|
96
|
-
error: undefined,
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
createAutoTransferRuleSuccess(draft, action) {
|
|
100
|
-
draft.rules = [...draft.rules, action.payload.rule];
|
|
101
|
-
draft.createRuleFetchState = {
|
|
102
|
-
fetchState: 'Completed',
|
|
103
|
-
error: undefined,
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
createAutoTransferRuleFailure(draft, action) {
|
|
107
|
-
draft.createRuleFetchState = {
|
|
108
|
-
fetchState: action.payload.fetchState,
|
|
109
|
-
error: action.payload.error,
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
updateAutoTransferRule: {
|
|
113
|
-
reducer(draft, action) {
|
|
114
|
-
draft.ruleUpdateStatusById[action.payload.ruleId] = {
|
|
115
|
-
fetchState: 'In-Progress',
|
|
116
|
-
error: undefined,
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
prepare(ruleId, pauseRule, resumeRule) {
|
|
120
|
-
return { payload: { ruleId, pauseRule, resumeRule } };
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
updateAutoTransferRuleSuccess(draft, action) {
|
|
124
|
-
const updatedRule = action.payload.rule;
|
|
125
|
-
draft.rules = draft.rules.map((rule) => rule.autoTransferRuleId === updatedRule.autoTransferRuleId
|
|
126
|
-
? updatedRule
|
|
127
|
-
: rule);
|
|
128
|
-
draft.ruleUpdateStatusById[updatedRule.autoTransferRuleId] = {
|
|
129
|
-
fetchState: 'Completed',
|
|
130
|
-
error: undefined,
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
updateAutoTransferRuleFailure(draft, action) {
|
|
134
|
-
draft.ruleUpdateStatusById[action.payload.ruleId] = {
|
|
135
|
-
fetchState: action.payload.fetchState,
|
|
136
|
-
error: action.payload.error,
|
|
137
|
-
};
|
|
138
|
-
},
|
|
139
|
-
deleteAutoTransferRule: {
|
|
140
|
-
reducer(draft, action) {
|
|
141
|
-
draft.ruleDeleteStatusById[action.payload.ruleId] = {
|
|
142
|
-
fetchState: 'In-Progress',
|
|
143
|
-
error: undefined,
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
prepare(ruleId) {
|
|
147
|
-
return { payload: { ruleId } };
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
deleteAutoTransferRuleSuccess(draft, action) {
|
|
151
|
-
const { ruleId } = action.payload;
|
|
152
|
-
draft.rules = draft.rules.filter((rule) => rule.autoTransferRuleId !== ruleId);
|
|
153
|
-
draft.ruleDeleteStatusById[ruleId] = {
|
|
154
|
-
fetchState: 'Completed',
|
|
155
|
-
error: undefined,
|
|
156
|
-
};
|
|
157
|
-
},
|
|
158
|
-
deleteAutoTransferRuleFailure(draft, action) {
|
|
159
|
-
draft.ruleDeleteStatusById[action.payload.ruleId] = {
|
|
160
|
-
fetchState: action.payload.fetchState,
|
|
161
|
-
error: action.payload.error,
|
|
162
|
-
};
|
|
163
|
-
},
|
|
164
|
-
fetchAutoTransferRuleHistory: {
|
|
165
|
-
reducer(draft, action) {
|
|
166
|
-
const { ruleId, cacheOverride } = action.payload;
|
|
167
|
-
const detail = (0, get_1.default)(draft.historyByRuleId, ruleId, undefined);
|
|
168
|
-
if (cacheOverride === true ||
|
|
169
|
-
detail == null ||
|
|
170
|
-
detail.fetchState !== 'In-Progress') {
|
|
171
|
-
draft.historyByRuleId[ruleId] = {
|
|
172
|
-
...commonHistory_1.initialCommonHistory,
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
prepare(ruleId, cacheOverride = true) {
|
|
177
|
-
return {
|
|
178
|
-
payload: { ruleId, cacheOverride },
|
|
179
|
-
};
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
updateAutoTransferRuleHistory(draft, action) {
|
|
183
|
-
const { ruleId, historicEventsPayload } = action.payload;
|
|
184
|
-
const historicEvents = historicEventsPayload.map((historicEventPayload) => (0, commonHistoryPayload_1.toHistoricEvent)(historicEventPayload));
|
|
185
|
-
draft.historyByRuleId[ruleId] = {
|
|
186
|
-
...commonHistory_1.initialCommonHistory,
|
|
187
|
-
fetchState: 'Completed',
|
|
188
|
-
error: undefined,
|
|
189
|
-
historicEvents,
|
|
190
|
-
};
|
|
191
|
-
},
|
|
192
|
-
updateAutoTransferRuleHistoryFetchStatus(draft, action) {
|
|
193
|
-
const { ruleId, fetchState, error } = action.payload;
|
|
194
|
-
const detail = (0, get_1.default)(draft.historyByRuleId, ruleId, undefined);
|
|
195
|
-
if (detail != null) {
|
|
196
|
-
detail.fetchState = fetchState;
|
|
197
|
-
detail.error = error;
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
clearAutoTransferRules(draft) {
|
|
201
|
-
Object.assign(draft, exports.initialState);
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
_a = autotransferRules.actions, exports.fetchAutoTransferRules = _a.fetchAutoTransferRules, exports.updateAutoTransferRules = _a.updateAutoTransferRules, exports.updateAutoTransferRulesFailure = _a.updateAutoTransferRulesFailure, exports.fetchAutoTransferReviewDetail = _a.fetchAutoTransferReviewDetail, exports.updateAutoTransferReviewDetail = _a.updateAutoTransferReviewDetail, exports.updateAutoTransferReviewDetailFailure = _a.updateAutoTransferReviewDetailFailure, exports.clearAutoTransferReviewDetail = _a.clearAutoTransferReviewDetail, exports.createAutoTransferRule = _a.createAutoTransferRule, exports.createAutoTransferRuleSuccess = _a.createAutoTransferRuleSuccess, exports.createAutoTransferRuleFailure = _a.createAutoTransferRuleFailure, exports.updateAutoTransferRule = _a.updateAutoTransferRule, exports.updateAutoTransferRuleSuccess = _a.updateAutoTransferRuleSuccess, exports.updateAutoTransferRuleFailure = _a.updateAutoTransferRuleFailure, exports.deleteAutoTransferRule = _a.deleteAutoTransferRule, exports.deleteAutoTransferRuleSuccess = _a.deleteAutoTransferRuleSuccess, exports.deleteAutoTransferRuleFailure = _a.deleteAutoTransferRuleFailure, exports.fetchAutoTransferRuleHistory = _a.fetchAutoTransferRuleHistory, exports.updateAutoTransferRuleHistory = _a.updateAutoTransferRuleHistory, exports.updateAutoTransferRuleHistoryFetchStatus = _a.updateAutoTransferRuleHistoryFetchStatus, exports.updateRuleLocalData = _a.updateRuleLocalData, exports.clearRuleUpdateLocalData = _a.clearRuleUpdateLocalData, exports.clearAutoTransferRules = _a.clearAutoTransferRules;
|
|
206
|
-
exports.default = autotransferRules.reducer;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FetchState, FetchStateAndError, ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import { SelectorView } from '../../../commonStateTypes/viewAndReport/viewAndReport';
|
|
3
|
-
import { RootState } from '../../../reducer';
|
|
4
|
-
import { CommonHistoryView } from '../commonHistoryView/commonHistory';
|
|
5
|
-
import { FundingAccount } from '../commonSetup/setupViewSelector';
|
|
6
|
-
import { TreasuryAccount } from '../treasury/treasuryTransferMoney/treasuryTransferMoneyState';
|
|
7
|
-
import { ReviewTransferDetail } from '../zeniAccounts/transferDetail/transferDetailState';
|
|
8
|
-
import { AutoTransferRuleLocalData } from './autoTransferRulesPayload';
|
|
9
|
-
import { AutoTransferRule } from './autoTransferRulesState';
|
|
10
|
-
export interface AutoTransferRulesSelectorView extends SelectorView {
|
|
11
|
-
autoTransferReviewDetail: ReviewTransferDetail;
|
|
12
|
-
createRuleFetchState: FetchStateAndError;
|
|
13
|
-
ruleDeleteStatusById: Record<ID, FetchStateAndError>;
|
|
14
|
-
rules: AutoTransferRule[];
|
|
15
|
-
ruleUpdateLocalData: AutoTransferRuleLocalData;
|
|
16
|
-
ruleUpdateStatusById: Record<ID, FetchStateAndError>;
|
|
17
|
-
transferMoneyParties: FundingAccount[];
|
|
18
|
-
transferMoneyPartiesFetchState: FetchState;
|
|
19
|
-
treasuryAccount: TreasuryAccount;
|
|
20
|
-
ruleHistory?: Record<string, CommonHistoryView>;
|
|
21
|
-
}
|
|
22
|
-
export declare const getAutoTransferRules: (state: RootState) => AutoTransferRulesSelectorView;
|
|
23
|
-
export declare const getAutoTransferRuleById: (state: RootState, ruleId: ID) => AutoTransferRule | undefined;
|
|
24
|
-
export declare const getAutoTransferRuleHistory: (state: RootState, ruleId: ID) => CommonHistoryView | undefined;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAutoTransferRuleHistory = exports.getAutoTransferRuleById = exports.getAutoTransferRules = void 0;
|
|
7
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
8
|
-
const reduceFetchState_1 = require("../../../commonStateTypes/reduceFetchState");
|
|
9
|
-
const setupViewSelector_1 = require("../commonSetup/setupViewSelector");
|
|
10
|
-
const depositAccountListSelector_1 = require("../zeniAccounts/depositAccountList/depositAccountListSelector");
|
|
11
|
-
const paymentAccountListSelector_1 = require("../zeniAccounts/paymentAccountList/paymentAccountListSelector");
|
|
12
|
-
const getAutoTransferRules = (state) => {
|
|
13
|
-
const { autotransferRulesState, depositAccountState, paymentAccountState, depositAccountListState, paymentAccountListState, treasuryDetailState, } = state;
|
|
14
|
-
const { rules, error, historyByRuleId, ruleUpdateLocalData, ruleUpdateStatusById, ruleDeleteStatusById, createRuleFetchState, autoTransferReviewDetail, } = autotransferRulesState;
|
|
15
|
-
const depositAccountsView = (0, depositAccountListSelector_1.getAllDepositAccounts)(depositAccountState, depositAccountListState);
|
|
16
|
-
const paymentAccountsView = (0, paymentAccountListSelector_1.getAllPaymentAccounts)(paymentAccountState, paymentAccountListState);
|
|
17
|
-
let transferMoneyParties = [];
|
|
18
|
-
const transferMoneyPartiesFetchState = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
19
|
-
depositAccountsView,
|
|
20
|
-
paymentAccountsView,
|
|
21
|
-
]).fetchState;
|
|
22
|
-
const fetchState = (0, reduceFetchState_1.reduceAllFetchState)([
|
|
23
|
-
autotransferRulesState,
|
|
24
|
-
depositAccountsView,
|
|
25
|
-
paymentAccountsView,
|
|
26
|
-
]).fetchState;
|
|
27
|
-
if (depositAccountsView.fetchState === 'Completed' &&
|
|
28
|
-
paymentAccountsView.fetchState === 'Completed') {
|
|
29
|
-
transferMoneyParties = (0, setupViewSelector_1.getAllFundingAccounts)(depositAccountsView.depositAccounts, paymentAccountsView.paymentAccounts, paymentAccountListState.paymentAccountBalanceFetchStatus);
|
|
30
|
-
}
|
|
31
|
-
const treasuryAccount = {
|
|
32
|
-
accType: 'treasuryAccount',
|
|
33
|
-
label: 'Treasury',
|
|
34
|
-
id: 'treasury',
|
|
35
|
-
balance: treasuryDetailState.accountSummary?.availableBalance,
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
autoTransferReviewDetail,
|
|
39
|
-
rules,
|
|
40
|
-
ruleUpdateLocalData,
|
|
41
|
-
ruleUpdateStatusById,
|
|
42
|
-
ruleDeleteStatusById,
|
|
43
|
-
ruleHistory: historyByRuleId,
|
|
44
|
-
treasuryAccount,
|
|
45
|
-
transferMoneyParties,
|
|
46
|
-
transferMoneyPartiesFetchState,
|
|
47
|
-
createRuleFetchState,
|
|
48
|
-
fetchState,
|
|
49
|
-
error,
|
|
50
|
-
version: 0,
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
exports.getAutoTransferRules = getAutoTransferRules;
|
|
54
|
-
const getAutoTransferRuleById = (state, ruleId) => {
|
|
55
|
-
return state.autotransferRulesState.rules.find((rule) => rule.autoTransferRuleId === ruleId);
|
|
56
|
-
};
|
|
57
|
-
exports.getAutoTransferRuleById = getAutoTransferRuleById;
|
|
58
|
-
const getAutoTransferRuleHistory = (state, ruleId) => {
|
|
59
|
-
return (0, get_1.default)(state.autotransferRulesState.historyByRuleId, ruleId, undefined);
|
|
60
|
-
};
|
|
61
|
-
exports.getAutoTransferRuleHistory = getAutoTransferRuleHistory;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { FetchStateAndError, FetchedState, ID } from '../../../commonStateTypes/common';
|
|
2
|
-
import { ZeniDate } from '../../../zeniDayJS';
|
|
3
|
-
import { CommonHistoryView } from '../commonHistoryView/commonHistory';
|
|
4
|
-
import { ReviewTransferDetail } from '../zeniAccounts/transferDetail/transferDetailState';
|
|
5
|
-
import { AutoTransferRuleFrequency, AutoTransferRuleLocalData, AutoTransferRuleType } from './autoTransferRulesPayload';
|
|
6
|
-
export interface AutoTransferRule {
|
|
7
|
-
amount: number;
|
|
8
|
-
autoTransferRuleId: ID;
|
|
9
|
-
currencyCode: string;
|
|
10
|
-
currencySymbol: string;
|
|
11
|
-
destinationBankAccountId: string | null;
|
|
12
|
-
frequency: AutoTransferRuleFrequency;
|
|
13
|
-
isActive: boolean;
|
|
14
|
-
isDeleted: boolean;
|
|
15
|
-
lastRunTime: string | null;
|
|
16
|
-
ruleType: AutoTransferRuleType;
|
|
17
|
-
sourceBankAccountId: string;
|
|
18
|
-
sourceBankAccountType: string;
|
|
19
|
-
createTime?: ZeniDate;
|
|
20
|
-
destinationBankAccountMetadata?: DestinationBankAccountMetadata[];
|
|
21
|
-
destinationBankAccountType?: string;
|
|
22
|
-
nextTransferDate?: ZeniDate;
|
|
23
|
-
updateTime?: ZeniDate;
|
|
24
|
-
}
|
|
25
|
-
export interface DestinationBankAccountMetadata {
|
|
26
|
-
accountId: string;
|
|
27
|
-
accountType: string;
|
|
28
|
-
percentage: number;
|
|
29
|
-
}
|
|
30
|
-
export interface AutoTransferRulesState extends FetchedState {
|
|
31
|
-
autoTransferReviewDetail: ReviewTransferDetail;
|
|
32
|
-
createRuleFetchState: FetchStateAndError;
|
|
33
|
-
historyByRuleId: Record<ID, CommonHistoryView>;
|
|
34
|
-
ruleDeleteStatusById: Record<ID, FetchStateAndError>;
|
|
35
|
-
rules: AutoTransferRule[];
|
|
36
|
-
ruleUpdateLocalData: AutoTransferRuleLocalData;
|
|
37
|
-
ruleUpdateStatusById: Record<ID, FetchStateAndError>;
|
|
38
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { openSnackbar } from '../../../../entity/snackbar/snackbarReducer';
|
|
4
|
-
import { RootState } from '../../../../reducer';
|
|
5
|
-
import { ZeniAPI } from '../../../../zeniAPI';
|
|
6
|
-
import { AccType, AccountTypeSubConfigCodeKeyType } from '../../billPay/billPayConfig/billPayConfigState';
|
|
7
|
-
import { AutoTransferRuleLocalData, AutoTransferRuleRequestBody } from '../autoTransferRulesPayload';
|
|
8
|
-
import { createAutoTransferRule, createAutoTransferRuleFailure, createAutoTransferRuleSuccess } from '../autoTransferRulesReducer';
|
|
9
|
-
export type ActionType = ReturnType<typeof createAutoTransferRule> | ReturnType<typeof createAutoTransferRuleSuccess> | ReturnType<typeof createAutoTransferRuleFailure> | ReturnType<typeof openSnackbar>;
|
|
10
|
-
export declare const createAutoTransferRuleEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
11
|
-
export declare function mapAutoTransferRuleLocalDataToPayload(localData: AutoTransferRuleLocalData, pauseRule?: boolean, resumeRule?: boolean): AutoTransferRuleRequestBody;
|
|
12
|
-
export declare const accountTypeSubConfigCodeToAccType: (code?: AccountTypeSubConfigCodeKeyType | "treasuryAccount") => AccType | "treasury_account" | undefined;
|