@cranberry-money/shared-services 4.0.0 → 8.0.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/package.json +4 -3
- package/dist/api/functional-client.d.ts +0 -66
- package/dist/api/functional-client.d.ts.map +0 -1
- package/dist/api/functional-client.js +0 -165
- package/dist/auth/functional/auth-operations.d.ts +0 -116
- package/dist/auth/functional/auth-operations.d.ts.map +0 -1
- package/dist/auth/functional/auth-operations.js +0 -246
- package/dist/auth/functional/auth-state.d.ts +0 -38
- package/dist/auth/functional/auth-state.d.ts.map +0 -1
- package/dist/auth/functional/auth-state.js +0 -87
- package/dist/auth/functional/token-storage.d.ts +0 -44
- package/dist/auth/functional/token-storage.d.ts.map +0 -1
- package/dist/auth/functional/token-storage.js +0 -178
- package/dist/auth/react/AuthProvider.d.ts +0 -92
- package/dist/auth/react/AuthProvider.d.ts.map +0 -1
- package/dist/auth/react/AuthProvider.js +0 -207
- package/dist/integration/blueberry-integration.d.ts +0 -21
- package/dist/integration/blueberry-integration.d.ts.map +0 -1
- package/dist/integration/blueberry-integration.js +0 -109
- package/dist/integration/index.d.ts +0 -8
- package/dist/integration/index.d.ts.map +0 -1
- package/dist/integration/index.js +0 -18
- package/dist/services/accounts.d.ts +0 -220
- package/dist/services/accounts.d.ts.map +0 -1
- package/dist/services/accounts.js +0 -175
- package/dist/services/banks.d.ts +0 -123
- package/dist/services/banks.d.ts.map +0 -1
- package/dist/services/banks.js +0 -151
- package/dist/services/cash-accounts.d.ts +0 -112
- package/dist/services/cash-accounts.d.ts.map +0 -1
- package/dist/services/cash-accounts.js +0 -222
- package/dist/services/documents.d.ts +0 -143
- package/dist/services/documents.d.ts.map +0 -1
- package/dist/services/documents.js +0 -253
- package/dist/services/factories/account-factory.d.ts +0 -16
- package/dist/services/factories/account-factory.d.ts.map +0 -1
- package/dist/services/factories/account-factory.js +0 -79
- package/dist/services/factories/auth-factory.d.ts +0 -23
- package/dist/services/factories/auth-factory.d.ts.map +0 -1
- package/dist/services/factories/auth-factory.js +0 -75
- package/dist/services/factories/bank-factory.d.ts +0 -16
- package/dist/services/factories/bank-factory.d.ts.map +0 -1
- package/dist/services/factories/bank-factory.js +0 -72
- package/dist/services/factories/cash-account-factory.d.ts +0 -16
- package/dist/services/factories/cash-account-factory.d.ts.map +0 -1
- package/dist/services/factories/cash-account-factory.js +0 -74
- package/dist/services/factories/document-factory.d.ts +0 -16
- package/dist/services/factories/document-factory.d.ts.map +0 -1
- package/dist/services/factories/document-factory.js +0 -85
- package/dist/services/factories/index.d.ts +0 -21
- package/dist/services/factories/index.d.ts.map +0 -1
- package/dist/services/factories/index.js +0 -40
- package/dist/services/factories/instrument-factory.d.ts +0 -16
- package/dist/services/factories/instrument-factory.d.ts.map +0 -1
- package/dist/services/factories/instrument-factory.js +0 -68
- package/dist/services/factories/master-factory.d.ts +0 -74
- package/dist/services/factories/master-factory.d.ts.map +0 -1
- package/dist/services/factories/master-factory.js +0 -183
- package/dist/services/factories/portfolio-factory.d.ts +0 -16
- package/dist/services/factories/portfolio-factory.d.ts.map +0 -1
- package/dist/services/factories/portfolio-factory.js +0 -74
- package/dist/services/factories/portfolio-template-factory.d.ts +0 -16
- package/dist/services/factories/portfolio-template-factory.d.ts.map +0 -1
- package/dist/services/factories/portfolio-template-factory.js +0 -76
- package/dist/services/factories/reference-data-factory.d.ts +0 -16
- package/dist/services/factories/reference-data-factory.d.ts.map +0 -1
- package/dist/services/factories/reference-data-factory.js +0 -86
- package/dist/services/factories/tax-residency-factory.d.ts +0 -16
- package/dist/services/factories/tax-residency-factory.d.ts.map +0 -1
- package/dist/services/factories/tax-residency-factory.js +0 -73
- package/dist/services/factories/trade-factory.d.ts +0 -16
- package/dist/services/factories/trade-factory.d.ts.map +0 -1
- package/dist/services/factories/trade-factory.js +0 -79
- package/dist/services/factories/types.d.ts +0 -250
- package/dist/services/factories/types.d.ts.map +0 -1
- package/dist/services/factories/types.js +0 -32
- package/dist/services/factories/withdrawal-factory.d.ts +0 -16
- package/dist/services/factories/withdrawal-factory.d.ts.map +0 -1
- package/dist/services/factories/withdrawal-factory.js +0 -78
- package/dist/services/instruments.d.ts +0 -138
- package/dist/services/instruments.d.ts.map +0 -1
- package/dist/services/instruments.js +0 -178
- package/dist/services/portfolio-templates.d.ts +0 -142
- package/dist/services/portfolio-templates.d.ts.map +0 -1
- package/dist/services/portfolio-templates.js +0 -201
- package/dist/services/portfolios.d.ts +0 -157
- package/dist/services/portfolios.d.ts.map +0 -1
- package/dist/services/portfolios.js +0 -144
- package/dist/services/reference-data.d.ts +0 -185
- package/dist/services/reference-data.d.ts.map +0 -1
- package/dist/services/reference-data.js +0 -245
- package/dist/services/tax-residencies.d.ts +0 -83
- package/dist/services/tax-residencies.d.ts.map +0 -1
- package/dist/services/tax-residencies.js +0 -179
- package/dist/services/trades.d.ts +0 -190
- package/dist/services/trades.d.ts.map +0 -1
- package/dist/services/trades.js +0 -207
- package/dist/services/withdrawals.d.ts +0 -236
- package/dist/services/withdrawals.d.ts.map +0 -1
- package/dist/services/withdrawals.js +0 -345
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Withdrawal Services - Pure Functional Implementation
|
|
3
|
-
*
|
|
4
|
-
* Complete withdrawal request and liquidation workflow system.
|
|
5
|
-
* Pure functions with explicit dependencies for withdrawal management.
|
|
6
|
-
*/
|
|
7
|
-
import type { ApiClient } from '../api/functional-client';
|
|
8
|
-
export type WithdrawalStatus = 'PENDING_REVIEW' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'AWAITING_LIQUIDATION' | 'LIQUIDATION_IN_PROGRESS' | 'COMPLETED' | 'CANCELLED' | 'FAILED';
|
|
9
|
-
export type WithdrawalType = 'FULL_CASH' | 'PARTIAL_CASH';
|
|
10
|
-
export type WithdrawalReason = 'INVESTMENT_STRATEGY' | 'PERSONAL_EXPENSES' | 'EMERGENCY' | 'OTHER';
|
|
11
|
-
export interface WithdrawalRequest {
|
|
12
|
-
readonly uuid: string;
|
|
13
|
-
readonly account: string;
|
|
14
|
-
readonly requestedBy: string;
|
|
15
|
-
readonly requestedAmount: string;
|
|
16
|
-
readonly withdrawalType: WithdrawalType;
|
|
17
|
-
readonly status: WithdrawalStatus;
|
|
18
|
-
readonly requestedDate: string;
|
|
19
|
-
readonly targetTradeSheet: string | null;
|
|
20
|
-
readonly reason: WithdrawalReason | null;
|
|
21
|
-
readonly createdAt: string;
|
|
22
|
-
readonly updatedAt: string;
|
|
23
|
-
}
|
|
24
|
-
export interface CreateWithdrawalRequestPayload {
|
|
25
|
-
readonly account: string;
|
|
26
|
-
readonly requestedAmount: string;
|
|
27
|
-
readonly withdrawalType?: WithdrawalType;
|
|
28
|
-
readonly targetTradeSheet?: string | null;
|
|
29
|
-
readonly reason?: WithdrawalReason | null;
|
|
30
|
-
}
|
|
31
|
-
export interface UpdateWithdrawalRequestPayload {
|
|
32
|
-
readonly requestedAmount?: string;
|
|
33
|
-
readonly withdrawalType?: WithdrawalType;
|
|
34
|
-
readonly status?: WithdrawalStatus;
|
|
35
|
-
readonly targetTradeSheet?: string | null;
|
|
36
|
-
readonly reason?: WithdrawalReason | null;
|
|
37
|
-
}
|
|
38
|
-
export interface WithdrawalRequestFilters {
|
|
39
|
-
readonly account?: string;
|
|
40
|
-
readonly status?: WithdrawalStatus;
|
|
41
|
-
readonly withdrawalType?: WithdrawalType;
|
|
42
|
-
readonly startDate?: string;
|
|
43
|
-
readonly endDate?: string;
|
|
44
|
-
readonly minAmount?: string;
|
|
45
|
-
readonly maxAmount?: string;
|
|
46
|
-
readonly ordering?: string;
|
|
47
|
-
readonly page?: number;
|
|
48
|
-
readonly pageSize?: number;
|
|
49
|
-
}
|
|
50
|
-
export interface PaginatedWithdrawalRequests {
|
|
51
|
-
readonly results: WithdrawalRequest[];
|
|
52
|
-
readonly count: number;
|
|
53
|
-
readonly next: string | null;
|
|
54
|
-
readonly previous: string | null;
|
|
55
|
-
}
|
|
56
|
-
export type WithdrawalLiquidationStatus = 'PENDING' | 'TRADES_CREATED' | 'EXECUTED' | 'SETTLED' | 'FAILED';
|
|
57
|
-
export interface WithdrawalAssetLiquidation {
|
|
58
|
-
readonly uuid: string;
|
|
59
|
-
readonly withdrawalRequest: string;
|
|
60
|
-
readonly assetHolding: string;
|
|
61
|
-
readonly sharesToLiquidate: number;
|
|
62
|
-
readonly estimatedValue: string;
|
|
63
|
-
readonly targetCompletionDate: string | null;
|
|
64
|
-
readonly expectedSettlementDate: string | null;
|
|
65
|
-
readonly liquidationStatus: WithdrawalLiquidationStatus;
|
|
66
|
-
readonly targetTrade: string | null;
|
|
67
|
-
readonly instrumentName: string;
|
|
68
|
-
readonly instrumentSymbol: string;
|
|
69
|
-
readonly instrumentCurrency: string | null;
|
|
70
|
-
readonly createdAt: string;
|
|
71
|
-
readonly updatedAt: string;
|
|
72
|
-
}
|
|
73
|
-
export interface CreateWithdrawalLiquidationPayload {
|
|
74
|
-
readonly withdrawalRequest: string;
|
|
75
|
-
readonly assetHolding: string;
|
|
76
|
-
readonly sharesToLiquidate: number;
|
|
77
|
-
readonly estimatedValue: string;
|
|
78
|
-
readonly targetCompletionDate?: string | null;
|
|
79
|
-
readonly expectedSettlementDate?: string | null;
|
|
80
|
-
readonly liquidationStatus?: WithdrawalLiquidationStatus;
|
|
81
|
-
readonly targetTrade?: string | null;
|
|
82
|
-
}
|
|
83
|
-
export interface UpdateWithdrawalLiquidationPayload {
|
|
84
|
-
readonly sharesToLiquidate?: number;
|
|
85
|
-
readonly estimatedValue?: string;
|
|
86
|
-
readonly targetCompletionDate?: string | null;
|
|
87
|
-
readonly expectedSettlementDate?: string | null;
|
|
88
|
-
readonly liquidationStatus?: WithdrawalLiquidationStatus;
|
|
89
|
-
readonly targetTrade?: string | null;
|
|
90
|
-
}
|
|
91
|
-
export interface WithdrawalLiquidationFilters {
|
|
92
|
-
readonly withdrawalRequest?: string;
|
|
93
|
-
readonly assetHolding?: string;
|
|
94
|
-
readonly liquidationStatus?: WithdrawalLiquidationStatus;
|
|
95
|
-
readonly targetCompletionStartDate?: string;
|
|
96
|
-
readonly targetCompletionEndDate?: string;
|
|
97
|
-
readonly expectedSettlementStartDate?: string;
|
|
98
|
-
readonly expectedSettlementEndDate?: string;
|
|
99
|
-
readonly targetTrade?: string;
|
|
100
|
-
readonly minValue?: string;
|
|
101
|
-
readonly maxValue?: string;
|
|
102
|
-
readonly ordering?: string;
|
|
103
|
-
readonly page?: number;
|
|
104
|
-
readonly pageSize?: number;
|
|
105
|
-
}
|
|
106
|
-
export interface PaginatedWithdrawalLiquidations {
|
|
107
|
-
readonly results: WithdrawalAssetLiquidation[];
|
|
108
|
-
readonly count: number;
|
|
109
|
-
readonly next: string | null;
|
|
110
|
-
readonly previous: string | null;
|
|
111
|
-
}
|
|
112
|
-
export declare const getWithdrawalRequests: ({ apiClient }: {
|
|
113
|
-
apiClient: ApiClient;
|
|
114
|
-
}, filters?: WithdrawalRequestFilters) => Promise<PaginatedWithdrawalRequests>;
|
|
115
|
-
export declare const getWithdrawalRequest: ({ apiClient }: {
|
|
116
|
-
apiClient: ApiClient;
|
|
117
|
-
}, uuid: string) => Promise<WithdrawalRequest>;
|
|
118
|
-
export declare const createWithdrawalRequest: ({ apiClient }: {
|
|
119
|
-
apiClient: ApiClient;
|
|
120
|
-
}, data: CreateWithdrawalRequestPayload) => Promise<WithdrawalRequest>;
|
|
121
|
-
export declare const updateWithdrawalRequest: ({ apiClient }: {
|
|
122
|
-
apiClient: ApiClient;
|
|
123
|
-
}, uuid: string, data: UpdateWithdrawalRequestPayload) => Promise<WithdrawalRequest>;
|
|
124
|
-
export declare const deleteWithdrawalRequest: ({ apiClient }: {
|
|
125
|
-
apiClient: ApiClient;
|
|
126
|
-
}, uuid: string) => Promise<void>;
|
|
127
|
-
export declare const approveWithdrawalRequest: ({ apiClient }: {
|
|
128
|
-
apiClient: ApiClient;
|
|
129
|
-
}, uuid: string) => Promise<WithdrawalRequest>;
|
|
130
|
-
export declare const rejectWithdrawalRequest: ({ apiClient }: {
|
|
131
|
-
apiClient: ApiClient;
|
|
132
|
-
}, uuid: string, reason?: string) => Promise<WithdrawalRequest>;
|
|
133
|
-
export declare const cancelWithdrawalRequest: ({ apiClient }: {
|
|
134
|
-
apiClient: ApiClient;
|
|
135
|
-
}, uuid: string) => Promise<WithdrawalRequest>;
|
|
136
|
-
export declare const processWithdrawalRequest: ({ apiClient }: {
|
|
137
|
-
apiClient: ApiClient;
|
|
138
|
-
}, uuid: string) => Promise<WithdrawalRequest>;
|
|
139
|
-
export declare const getWithdrawalLiquidations: ({ apiClient }: {
|
|
140
|
-
apiClient: ApiClient;
|
|
141
|
-
}, filters?: WithdrawalLiquidationFilters) => Promise<PaginatedWithdrawalLiquidations>;
|
|
142
|
-
export declare const getWithdrawalLiquidation: ({ apiClient }: {
|
|
143
|
-
apiClient: ApiClient;
|
|
144
|
-
}, uuid: string) => Promise<WithdrawalAssetLiquidation>;
|
|
145
|
-
export declare const createWithdrawalLiquidation: ({ apiClient }: {
|
|
146
|
-
apiClient: ApiClient;
|
|
147
|
-
}, data: CreateWithdrawalLiquidationPayload) => Promise<WithdrawalAssetLiquidation>;
|
|
148
|
-
export declare const updateWithdrawalLiquidation: ({ apiClient }: {
|
|
149
|
-
apiClient: ApiClient;
|
|
150
|
-
}, uuid: string, data: UpdateWithdrawalLiquidationPayload) => Promise<WithdrawalAssetLiquidation>;
|
|
151
|
-
export declare const deleteWithdrawalLiquidation: ({ apiClient }: {
|
|
152
|
-
apiClient: ApiClient;
|
|
153
|
-
}, uuid: string) => Promise<void>;
|
|
154
|
-
export declare const getLiquidationsByWithdrawalRequest: ({ apiClient }: {
|
|
155
|
-
apiClient: ApiClient;
|
|
156
|
-
}, withdrawalRequestUuid: string) => Promise<PaginatedWithdrawalLiquidations>;
|
|
157
|
-
export declare const createTradesForLiquidation: ({ apiClient }: {
|
|
158
|
-
apiClient: ApiClient;
|
|
159
|
-
}, uuid: string) => Promise<WithdrawalAssetLiquidation>;
|
|
160
|
-
export declare const executeLiquidationTrades: ({ apiClient }: {
|
|
161
|
-
apiClient: ApiClient;
|
|
162
|
-
}, uuid: string) => Promise<WithdrawalAssetLiquidation>;
|
|
163
|
-
export declare const WITHDRAWAL_STATUS: {
|
|
164
|
-
PENDING_REVIEW: "PENDING_REVIEW";
|
|
165
|
-
APPROVED: "APPROVED";
|
|
166
|
-
REJECTED: "REJECTED";
|
|
167
|
-
PROCESSING: "PROCESSING";
|
|
168
|
-
AWAITING_LIQUIDATION: "AWAITING_LIQUIDATION";
|
|
169
|
-
LIQUIDATION_IN_PROGRESS: "LIQUIDATION_IN_PROGRESS";
|
|
170
|
-
COMPLETED: "COMPLETED";
|
|
171
|
-
CANCELLED: "CANCELLED";
|
|
172
|
-
FAILED: "FAILED";
|
|
173
|
-
};
|
|
174
|
-
export declare const WITHDRAWAL_STATUS_LABELS: {
|
|
175
|
-
readonly PENDING_REVIEW: "Pending Review";
|
|
176
|
-
readonly APPROVED: "Approved";
|
|
177
|
-
readonly REJECTED: "Rejected";
|
|
178
|
-
readonly PROCESSING: "Processing";
|
|
179
|
-
readonly AWAITING_LIQUIDATION: "Awaiting Liquidation";
|
|
180
|
-
readonly LIQUIDATION_IN_PROGRESS: "Liquidation In Progress";
|
|
181
|
-
readonly COMPLETED: "Completed";
|
|
182
|
-
readonly CANCELLED: "Cancelled";
|
|
183
|
-
readonly FAILED: "Failed";
|
|
184
|
-
};
|
|
185
|
-
export declare const WITHDRAWAL_TYPE: {
|
|
186
|
-
FULL_CASH: "FULL_CASH";
|
|
187
|
-
PARTIAL_CASH: "PARTIAL_CASH";
|
|
188
|
-
};
|
|
189
|
-
export declare const WITHDRAWAL_TYPE_LABELS: {
|
|
190
|
-
readonly FULL_CASH: "Full Cash Withdrawal";
|
|
191
|
-
readonly PARTIAL_CASH: "Partial Cash Withdrawal";
|
|
192
|
-
};
|
|
193
|
-
export declare const WITHDRAWAL_REASON: {
|
|
194
|
-
INVESTMENT_STRATEGY: "INVESTMENT_STRATEGY";
|
|
195
|
-
PERSONAL_EXPENSES: "PERSONAL_EXPENSES";
|
|
196
|
-
EMERGENCY: "EMERGENCY";
|
|
197
|
-
OTHER: "OTHER";
|
|
198
|
-
};
|
|
199
|
-
export declare const WITHDRAWAL_REASON_LABELS: {
|
|
200
|
-
readonly INVESTMENT_STRATEGY: "Investment Strategy";
|
|
201
|
-
readonly PERSONAL_EXPENSES: "Personal Expenses";
|
|
202
|
-
readonly EMERGENCY: "Emergency";
|
|
203
|
-
readonly OTHER: "Other";
|
|
204
|
-
};
|
|
205
|
-
export declare const LIQUIDATION_STATUS: {
|
|
206
|
-
PENDING: "PENDING";
|
|
207
|
-
TRADES_CREATED: "TRADES_CREATED";
|
|
208
|
-
EXECUTED: "EXECUTED";
|
|
209
|
-
SETTLED: "SETTLED";
|
|
210
|
-
FAILED: "FAILED";
|
|
211
|
-
};
|
|
212
|
-
export declare const LIQUIDATION_STATUS_LABELS: {
|
|
213
|
-
readonly PENDING: "Pending";
|
|
214
|
-
readonly TRADES_CREATED: "Trades Created";
|
|
215
|
-
readonly EXECUTED: "Executed";
|
|
216
|
-
readonly SETTLED: "Settled";
|
|
217
|
-
readonly FAILED: "Failed";
|
|
218
|
-
};
|
|
219
|
-
export declare const formatWithdrawalAmount: (amount: string | number) => string;
|
|
220
|
-
export declare const getWithdrawalStatusColor: (status: WithdrawalStatus) => string;
|
|
221
|
-
export declare const getLiquidationStatusColor: (status: WithdrawalLiquidationStatus) => string;
|
|
222
|
-
export declare const calculateLiquidationProgress: (liquidations: WithdrawalAssetLiquidation[]) => {
|
|
223
|
-
total: number;
|
|
224
|
-
pending: number;
|
|
225
|
-
inProgress: number;
|
|
226
|
-
completed: number;
|
|
227
|
-
failed: number;
|
|
228
|
-
completionRate: number;
|
|
229
|
-
};
|
|
230
|
-
export declare const getTotalEstimatedValue: (liquidations: WithdrawalAssetLiquidation[]) => number;
|
|
231
|
-
export declare const formatSharesQuantity: (shares: number) => string;
|
|
232
|
-
export declare const isWithdrawalEditable: (status: WithdrawalStatus) => boolean;
|
|
233
|
-
export declare const isWithdrawalCancellable: (status: WithdrawalStatus) => boolean;
|
|
234
|
-
export declare const canCreateLiquidations: (status: WithdrawalStatus) => boolean;
|
|
235
|
-
export declare const canProcessWithdrawal: (status: WithdrawalStatus) => boolean;
|
|
236
|
-
//# sourceMappingURL=withdrawals.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"withdrawals.d.ts","sourceRoot":"","sources":["../../src/services/withdrawals.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAM1D,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,UAAU,GACV,UAAU,GACV,YAAY,GACZ,sBAAsB,GACtB,yBAAyB,GACzB,WAAW,GACX,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,cAAc,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,WAAW,GAAG,OAAO,CAAC;AAEnG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE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AC;AAEF,eAAO,MAAM,qBAAqB,GAAI,QAAQ,gBAAgB,KAAG,OAEhE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,gBAAgB,KAAG,OAE/D,CAAC"}
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Withdrawal Services - Pure Functional Implementation
|
|
4
|
-
*
|
|
5
|
-
* Complete withdrawal request and liquidation workflow system.
|
|
6
|
-
* Pure functions with explicit dependencies for withdrawal management.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.canProcessWithdrawal = exports.canCreateLiquidations = exports.isWithdrawalCancellable = exports.isWithdrawalEditable = exports.formatSharesQuantity = exports.getTotalEstimatedValue = exports.calculateLiquidationProgress = exports.getLiquidationStatusColor = exports.getWithdrawalStatusColor = exports.formatWithdrawalAmount = exports.LIQUIDATION_STATUS_LABELS = exports.LIQUIDATION_STATUS = exports.WITHDRAWAL_REASON_LABELS = exports.WITHDRAWAL_REASON = exports.WITHDRAWAL_TYPE_LABELS = exports.WITHDRAWAL_TYPE = exports.WITHDRAWAL_STATUS_LABELS = exports.WITHDRAWAL_STATUS = exports.executeLiquidationTrades = exports.createTradesForLiquidation = exports.getLiquidationsByWithdrawalRequest = exports.deleteWithdrawalLiquidation = exports.updateWithdrawalLiquidation = exports.createWithdrawalLiquidation = exports.getWithdrawalLiquidation = exports.getWithdrawalLiquidations = exports.processWithdrawalRequest = exports.cancelWithdrawalRequest = exports.rejectWithdrawalRequest = exports.approveWithdrawalRequest = exports.deleteWithdrawalRequest = exports.updateWithdrawalRequest = exports.createWithdrawalRequest = exports.getWithdrawalRequest = exports.getWithdrawalRequests = void 0;
|
|
10
|
-
// =============================
|
|
11
|
-
// WITHDRAWAL REQUEST OPERATIONS
|
|
12
|
-
// =============================
|
|
13
|
-
const getWithdrawalRequests = async ({ apiClient }, filters) => {
|
|
14
|
-
const params = {};
|
|
15
|
-
if (filters?.account)
|
|
16
|
-
params.account = filters.account;
|
|
17
|
-
if (filters?.status)
|
|
18
|
-
params.status = filters.status;
|
|
19
|
-
if (filters?.withdrawalType)
|
|
20
|
-
params.withdrawal_type = filters.withdrawalType;
|
|
21
|
-
if (filters?.startDate)
|
|
22
|
-
params.start_date = filters.startDate;
|
|
23
|
-
if (filters?.endDate)
|
|
24
|
-
params.end_date = filters.endDate;
|
|
25
|
-
if (filters?.minAmount)
|
|
26
|
-
params.min_amount = filters.minAmount;
|
|
27
|
-
if (filters?.maxAmount)
|
|
28
|
-
params.max_amount = filters.maxAmount;
|
|
29
|
-
if (filters?.ordering)
|
|
30
|
-
params.order_by = filters.ordering;
|
|
31
|
-
if (filters?.page)
|
|
32
|
-
params.page = String(filters.page);
|
|
33
|
-
if (filters?.pageSize)
|
|
34
|
-
params.page_size = String(filters.pageSize);
|
|
35
|
-
return apiClient.get('/api/withdrawal-requests/', { params });
|
|
36
|
-
};
|
|
37
|
-
exports.getWithdrawalRequests = getWithdrawalRequests;
|
|
38
|
-
const getWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
39
|
-
if (!uuid?.trim()) {
|
|
40
|
-
throw new Error('Withdrawal request UUID is required');
|
|
41
|
-
}
|
|
42
|
-
return apiClient.get(`/api/withdrawal-requests/${uuid}/`);
|
|
43
|
-
};
|
|
44
|
-
exports.getWithdrawalRequest = getWithdrawalRequest;
|
|
45
|
-
const createWithdrawalRequest = async ({ apiClient }, data) => {
|
|
46
|
-
// Validation
|
|
47
|
-
if (!data.account?.trim()) {
|
|
48
|
-
throw new Error('Account UUID is required');
|
|
49
|
-
}
|
|
50
|
-
if (!data.requestedAmount || parseFloat(data.requestedAmount) <= 0) {
|
|
51
|
-
throw new Error('Requested amount must be greater than 0');
|
|
52
|
-
}
|
|
53
|
-
return apiClient.post('/api/withdrawal-requests/', data);
|
|
54
|
-
};
|
|
55
|
-
exports.createWithdrawalRequest = createWithdrawalRequest;
|
|
56
|
-
const updateWithdrawalRequest = async ({ apiClient }, uuid, data) => {
|
|
57
|
-
if (!uuid?.trim()) {
|
|
58
|
-
throw new Error('Withdrawal request UUID is required');
|
|
59
|
-
}
|
|
60
|
-
if (data.requestedAmount && parseFloat(data.requestedAmount) <= 0) {
|
|
61
|
-
throw new Error('Requested amount must be greater than 0');
|
|
62
|
-
}
|
|
63
|
-
return apiClient.patch(`/api/withdrawal-requests/${uuid}/`, data);
|
|
64
|
-
};
|
|
65
|
-
exports.updateWithdrawalRequest = updateWithdrawalRequest;
|
|
66
|
-
const deleteWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
67
|
-
if (!uuid?.trim()) {
|
|
68
|
-
throw new Error('Withdrawal request UUID is required');
|
|
69
|
-
}
|
|
70
|
-
await apiClient.delete(`/api/withdrawal-requests/${uuid}/`);
|
|
71
|
-
};
|
|
72
|
-
exports.deleteWithdrawalRequest = deleteWithdrawalRequest;
|
|
73
|
-
// Workflow operations
|
|
74
|
-
const approveWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
75
|
-
if (!uuid?.trim()) {
|
|
76
|
-
throw new Error('Withdrawal request UUID is required');
|
|
77
|
-
}
|
|
78
|
-
return apiClient.post(`/api/withdrawal-requests/${uuid}/approve/`, {});
|
|
79
|
-
};
|
|
80
|
-
exports.approveWithdrawalRequest = approveWithdrawalRequest;
|
|
81
|
-
const rejectWithdrawalRequest = async ({ apiClient }, uuid, reason) => {
|
|
82
|
-
if (!uuid?.trim()) {
|
|
83
|
-
throw new Error('Withdrawal request UUID is required');
|
|
84
|
-
}
|
|
85
|
-
return apiClient.post(`/api/withdrawal-requests/${uuid}/reject/`, { reason });
|
|
86
|
-
};
|
|
87
|
-
exports.rejectWithdrawalRequest = rejectWithdrawalRequest;
|
|
88
|
-
const cancelWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
89
|
-
if (!uuid?.trim()) {
|
|
90
|
-
throw new Error('Withdrawal request UUID is required');
|
|
91
|
-
}
|
|
92
|
-
return apiClient.post(`/api/withdrawal-requests/${uuid}/cancel/`, {});
|
|
93
|
-
};
|
|
94
|
-
exports.cancelWithdrawalRequest = cancelWithdrawalRequest;
|
|
95
|
-
const processWithdrawalRequest = async ({ apiClient }, uuid) => {
|
|
96
|
-
if (!uuid?.trim()) {
|
|
97
|
-
throw new Error('Withdrawal request UUID is required');
|
|
98
|
-
}
|
|
99
|
-
return apiClient.post(`/api/withdrawal-requests/${uuid}/process/`, {});
|
|
100
|
-
};
|
|
101
|
-
exports.processWithdrawalRequest = processWithdrawalRequest;
|
|
102
|
-
// =============================
|
|
103
|
-
// WITHDRAWAL LIQUIDATION OPERATIONS
|
|
104
|
-
// =============================
|
|
105
|
-
const getWithdrawalLiquidations = async ({ apiClient }, filters) => {
|
|
106
|
-
const params = {};
|
|
107
|
-
if (filters?.withdrawalRequest)
|
|
108
|
-
params.withdrawal_request = filters.withdrawalRequest;
|
|
109
|
-
if (filters?.assetHolding)
|
|
110
|
-
params.asset_holding = filters.assetHolding;
|
|
111
|
-
if (filters?.liquidationStatus)
|
|
112
|
-
params.liquidation_status = filters.liquidationStatus;
|
|
113
|
-
if (filters?.targetCompletionStartDate)
|
|
114
|
-
params.target_completion_start_date = filters.targetCompletionStartDate;
|
|
115
|
-
if (filters?.targetCompletionEndDate)
|
|
116
|
-
params.target_completion_end_date = filters.targetCompletionEndDate;
|
|
117
|
-
if (filters?.expectedSettlementStartDate)
|
|
118
|
-
params.expected_settlement_start_date = filters.expectedSettlementStartDate;
|
|
119
|
-
if (filters?.expectedSettlementEndDate)
|
|
120
|
-
params.expected_settlement_end_date = filters.expectedSettlementEndDate;
|
|
121
|
-
if (filters?.targetTrade)
|
|
122
|
-
params.target_trade = filters.targetTrade;
|
|
123
|
-
if (filters?.minValue)
|
|
124
|
-
params.min_value = filters.minValue;
|
|
125
|
-
if (filters?.maxValue)
|
|
126
|
-
params.max_value = filters.maxValue;
|
|
127
|
-
if (filters?.ordering)
|
|
128
|
-
params.order_by = filters.ordering;
|
|
129
|
-
if (filters?.page)
|
|
130
|
-
params.page = String(filters.page);
|
|
131
|
-
if (filters?.pageSize)
|
|
132
|
-
params.page_size = String(filters.pageSize);
|
|
133
|
-
return apiClient.get('/api/withdrawal-liquidations/', { params });
|
|
134
|
-
};
|
|
135
|
-
exports.getWithdrawalLiquidations = getWithdrawalLiquidations;
|
|
136
|
-
const getWithdrawalLiquidation = async ({ apiClient }, uuid) => {
|
|
137
|
-
if (!uuid?.trim()) {
|
|
138
|
-
throw new Error('Withdrawal liquidation UUID is required');
|
|
139
|
-
}
|
|
140
|
-
return apiClient.get(`/api/withdrawal-liquidations/${uuid}/`);
|
|
141
|
-
};
|
|
142
|
-
exports.getWithdrawalLiquidation = getWithdrawalLiquidation;
|
|
143
|
-
const createWithdrawalLiquidation = async ({ apiClient }, data) => {
|
|
144
|
-
// Validation
|
|
145
|
-
if (!data.withdrawalRequest?.trim()) {
|
|
146
|
-
throw new Error('Withdrawal request UUID is required');
|
|
147
|
-
}
|
|
148
|
-
if (!data.assetHolding?.trim()) {
|
|
149
|
-
throw new Error('Asset holding UUID is required');
|
|
150
|
-
}
|
|
151
|
-
if (!data.sharesToLiquidate || data.sharesToLiquidate <= 0) {
|
|
152
|
-
throw new Error('Shares to liquidate must be greater than 0');
|
|
153
|
-
}
|
|
154
|
-
if (!data.estimatedValue || parseFloat(data.estimatedValue) <= 0) {
|
|
155
|
-
throw new Error('Estimated value must be greater than 0');
|
|
156
|
-
}
|
|
157
|
-
return apiClient.post('/api/withdrawal-liquidations/', data);
|
|
158
|
-
};
|
|
159
|
-
exports.createWithdrawalLiquidation = createWithdrawalLiquidation;
|
|
160
|
-
const updateWithdrawalLiquidation = async ({ apiClient }, uuid, data) => {
|
|
161
|
-
if (!uuid?.trim()) {
|
|
162
|
-
throw new Error('Withdrawal liquidation UUID is required');
|
|
163
|
-
}
|
|
164
|
-
if (data.sharesToLiquidate !== undefined && data.sharesToLiquidate <= 0) {
|
|
165
|
-
throw new Error('Shares to liquidate must be greater than 0');
|
|
166
|
-
}
|
|
167
|
-
if (data.estimatedValue !== undefined && parseFloat(data.estimatedValue) <= 0) {
|
|
168
|
-
throw new Error('Estimated value must be greater than 0');
|
|
169
|
-
}
|
|
170
|
-
return apiClient.patch(`/api/withdrawal-liquidations/${uuid}/`, data);
|
|
171
|
-
};
|
|
172
|
-
exports.updateWithdrawalLiquidation = updateWithdrawalLiquidation;
|
|
173
|
-
const deleteWithdrawalLiquidation = async ({ apiClient }, uuid) => {
|
|
174
|
-
if (!uuid?.trim()) {
|
|
175
|
-
throw new Error('Withdrawal liquidation UUID is required');
|
|
176
|
-
}
|
|
177
|
-
await apiClient.delete(`/api/withdrawal-liquidations/${uuid}/`);
|
|
178
|
-
};
|
|
179
|
-
exports.deleteWithdrawalLiquidation = deleteWithdrawalLiquidation;
|
|
180
|
-
// Helper functions
|
|
181
|
-
const getLiquidationsByWithdrawalRequest = async ({ apiClient }, withdrawalRequestUuid) => {
|
|
182
|
-
if (!withdrawalRequestUuid?.trim()) {
|
|
183
|
-
throw new Error('Withdrawal request UUID is required');
|
|
184
|
-
}
|
|
185
|
-
return (0, exports.getWithdrawalLiquidations)({ apiClient }, {
|
|
186
|
-
withdrawalRequest: withdrawalRequestUuid,
|
|
187
|
-
ordering: '-created_at',
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
exports.getLiquidationsByWithdrawalRequest = getLiquidationsByWithdrawalRequest;
|
|
191
|
-
const createTradesForLiquidation = async ({ apiClient }, uuid) => {
|
|
192
|
-
if (!uuid?.trim()) {
|
|
193
|
-
throw new Error('Withdrawal liquidation UUID is required');
|
|
194
|
-
}
|
|
195
|
-
return apiClient.post(`/api/withdrawal-liquidations/${uuid}/create-trades/`, {});
|
|
196
|
-
};
|
|
197
|
-
exports.createTradesForLiquidation = createTradesForLiquidation;
|
|
198
|
-
const executeLiquidationTrades = async ({ apiClient }, uuid) => {
|
|
199
|
-
if (!uuid?.trim()) {
|
|
200
|
-
throw new Error('Withdrawal liquidation UUID is required');
|
|
201
|
-
}
|
|
202
|
-
return apiClient.post(`/api/withdrawal-liquidations/${uuid}/execute-trades/`, {});
|
|
203
|
-
};
|
|
204
|
-
exports.executeLiquidationTrades = executeLiquidationTrades;
|
|
205
|
-
// =============================
|
|
206
|
-
// UTILITY FUNCTIONS & CONSTANTS
|
|
207
|
-
// =============================
|
|
208
|
-
// Status constants
|
|
209
|
-
exports.WITHDRAWAL_STATUS = {
|
|
210
|
-
PENDING_REVIEW: 'PENDING_REVIEW',
|
|
211
|
-
APPROVED: 'APPROVED',
|
|
212
|
-
REJECTED: 'REJECTED',
|
|
213
|
-
PROCESSING: 'PROCESSING',
|
|
214
|
-
AWAITING_LIQUIDATION: 'AWAITING_LIQUIDATION',
|
|
215
|
-
LIQUIDATION_IN_PROGRESS: 'LIQUIDATION_IN_PROGRESS',
|
|
216
|
-
COMPLETED: 'COMPLETED',
|
|
217
|
-
CANCELLED: 'CANCELLED',
|
|
218
|
-
FAILED: 'FAILED',
|
|
219
|
-
};
|
|
220
|
-
exports.WITHDRAWAL_STATUS_LABELS = {
|
|
221
|
-
PENDING_REVIEW: 'Pending Review',
|
|
222
|
-
APPROVED: 'Approved',
|
|
223
|
-
REJECTED: 'Rejected',
|
|
224
|
-
PROCESSING: 'Processing',
|
|
225
|
-
AWAITING_LIQUIDATION: 'Awaiting Liquidation',
|
|
226
|
-
LIQUIDATION_IN_PROGRESS: 'Liquidation In Progress',
|
|
227
|
-
COMPLETED: 'Completed',
|
|
228
|
-
CANCELLED: 'Cancelled',
|
|
229
|
-
FAILED: 'Failed',
|
|
230
|
-
};
|
|
231
|
-
exports.WITHDRAWAL_TYPE = {
|
|
232
|
-
FULL_CASH: 'FULL_CASH',
|
|
233
|
-
PARTIAL_CASH: 'PARTIAL_CASH',
|
|
234
|
-
};
|
|
235
|
-
exports.WITHDRAWAL_TYPE_LABELS = {
|
|
236
|
-
FULL_CASH: 'Full Cash Withdrawal',
|
|
237
|
-
PARTIAL_CASH: 'Partial Cash Withdrawal',
|
|
238
|
-
};
|
|
239
|
-
exports.WITHDRAWAL_REASON = {
|
|
240
|
-
INVESTMENT_STRATEGY: 'INVESTMENT_STRATEGY',
|
|
241
|
-
PERSONAL_EXPENSES: 'PERSONAL_EXPENSES',
|
|
242
|
-
EMERGENCY: 'EMERGENCY',
|
|
243
|
-
OTHER: 'OTHER',
|
|
244
|
-
};
|
|
245
|
-
exports.WITHDRAWAL_REASON_LABELS = {
|
|
246
|
-
INVESTMENT_STRATEGY: 'Investment Strategy',
|
|
247
|
-
PERSONAL_EXPENSES: 'Personal Expenses',
|
|
248
|
-
EMERGENCY: 'Emergency',
|
|
249
|
-
OTHER: 'Other',
|
|
250
|
-
};
|
|
251
|
-
exports.LIQUIDATION_STATUS = {
|
|
252
|
-
PENDING: 'PENDING',
|
|
253
|
-
TRADES_CREATED: 'TRADES_CREATED',
|
|
254
|
-
EXECUTED: 'EXECUTED',
|
|
255
|
-
SETTLED: 'SETTLED',
|
|
256
|
-
FAILED: 'FAILED',
|
|
257
|
-
};
|
|
258
|
-
exports.LIQUIDATION_STATUS_LABELS = {
|
|
259
|
-
PENDING: 'Pending',
|
|
260
|
-
TRADES_CREATED: 'Trades Created',
|
|
261
|
-
EXECUTED: 'Executed',
|
|
262
|
-
SETTLED: 'Settled',
|
|
263
|
-
FAILED: 'Failed',
|
|
264
|
-
};
|
|
265
|
-
// Utility functions
|
|
266
|
-
const formatWithdrawalAmount = (amount) => {
|
|
267
|
-
const numValue = typeof amount === 'string' ? parseFloat(amount) : amount;
|
|
268
|
-
return new Intl.NumberFormat('en-AU', {
|
|
269
|
-
style: 'currency',
|
|
270
|
-
currency: 'AUD',
|
|
271
|
-
}).format(numValue);
|
|
272
|
-
};
|
|
273
|
-
exports.formatWithdrawalAmount = formatWithdrawalAmount;
|
|
274
|
-
const getWithdrawalStatusColor = (status) => {
|
|
275
|
-
const statusColors = {
|
|
276
|
-
PENDING_REVIEW: 'text-warning-600',
|
|
277
|
-
APPROVED: 'text-success-600',
|
|
278
|
-
REJECTED: 'text-error-600',
|
|
279
|
-
PROCESSING: 'text-primary-600',
|
|
280
|
-
AWAITING_LIQUIDATION: 'text-warning-600',
|
|
281
|
-
LIQUIDATION_IN_PROGRESS: 'text-primary-600',
|
|
282
|
-
COMPLETED: 'text-success-600',
|
|
283
|
-
CANCELLED: 'text-content-muted',
|
|
284
|
-
FAILED: 'text-error-600',
|
|
285
|
-
};
|
|
286
|
-
return statusColors[status] || 'text-content-muted';
|
|
287
|
-
};
|
|
288
|
-
exports.getWithdrawalStatusColor = getWithdrawalStatusColor;
|
|
289
|
-
const getLiquidationStatusColor = (status) => {
|
|
290
|
-
const statusColors = {
|
|
291
|
-
PENDING: 'text-warning-600',
|
|
292
|
-
TRADES_CREATED: 'text-primary-600',
|
|
293
|
-
EXECUTED: 'text-accent-secondary',
|
|
294
|
-
SETTLED: 'text-success-600',
|
|
295
|
-
FAILED: 'text-error-600',
|
|
296
|
-
};
|
|
297
|
-
return statusColors[status] || 'text-content-muted';
|
|
298
|
-
};
|
|
299
|
-
exports.getLiquidationStatusColor = getLiquidationStatusColor;
|
|
300
|
-
const calculateLiquidationProgress = (liquidations) => {
|
|
301
|
-
const total = liquidations.length;
|
|
302
|
-
const pending = liquidations.filter(l => l.liquidationStatus === 'PENDING').length;
|
|
303
|
-
const inProgress = liquidations.filter(l => ['TRADES_CREATED', 'EXECUTED'].includes(l.liquidationStatus)).length;
|
|
304
|
-
const completed = liquidations.filter(l => l.liquidationStatus === 'SETTLED').length;
|
|
305
|
-
const failed = liquidations.filter(l => l.liquidationStatus === 'FAILED').length;
|
|
306
|
-
const completionRate = total > 0 ? (completed / total) * 100 : 0;
|
|
307
|
-
return {
|
|
308
|
-
total,
|
|
309
|
-
pending,
|
|
310
|
-
inProgress,
|
|
311
|
-
completed,
|
|
312
|
-
failed,
|
|
313
|
-
completionRate,
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
exports.calculateLiquidationProgress = calculateLiquidationProgress;
|
|
317
|
-
const getTotalEstimatedValue = (liquidations) => {
|
|
318
|
-
return liquidations.reduce((total, liquidation) => {
|
|
319
|
-
return total + parseFloat(liquidation.estimatedValue || '0');
|
|
320
|
-
}, 0);
|
|
321
|
-
};
|
|
322
|
-
exports.getTotalEstimatedValue = getTotalEstimatedValue;
|
|
323
|
-
const formatSharesQuantity = (shares) => {
|
|
324
|
-
return new Intl.NumberFormat('en-AU', {
|
|
325
|
-
minimumFractionDigits: 0,
|
|
326
|
-
maximumFractionDigits: 4,
|
|
327
|
-
}).format(shares);
|
|
328
|
-
};
|
|
329
|
-
exports.formatSharesQuantity = formatSharesQuantity;
|
|
330
|
-
const isWithdrawalEditable = (status) => {
|
|
331
|
-
return ['PENDING_REVIEW', 'APPROVED'].includes(status);
|
|
332
|
-
};
|
|
333
|
-
exports.isWithdrawalEditable = isWithdrawalEditable;
|
|
334
|
-
const isWithdrawalCancellable = (status) => {
|
|
335
|
-
return ['PENDING_REVIEW', 'APPROVED', 'AWAITING_LIQUIDATION'].includes(status);
|
|
336
|
-
};
|
|
337
|
-
exports.isWithdrawalCancellable = isWithdrawalCancellable;
|
|
338
|
-
const canCreateLiquidations = (status) => {
|
|
339
|
-
return status === 'AWAITING_LIQUIDATION';
|
|
340
|
-
};
|
|
341
|
-
exports.canCreateLiquidations = canCreateLiquidations;
|
|
342
|
-
const canProcessWithdrawal = (status) => {
|
|
343
|
-
return status === 'APPROVED';
|
|
344
|
-
};
|
|
345
|
-
exports.canProcessWithdrawal = canProcessWithdrawal;
|