1use anyhow::Result;
2
3use super::super::commands::{
4 AccountFlagArgs, BizGroupArgs, BondAnswerStateArgs, BondPositionListArgs, BondSingleAssetArgs,
5 BondTotalAssetArgs, BondTradeReminderArgs, CashDetailArgs, CashLogArgs, MarginInfoArgs,
6};
7use crate::cmd;
8use crate::output::OutputFormat;
9
10pub(super) async fn dispatch_cash_log(
11 gateway: &str,
12 output: OutputFormat,
13 args: CashLogArgs,
14) -> Result<()> {
15 let CashLogArgs {
16 acc_id_pos,
17 acc_id,
18 card_num,
19 acc_id_file,
20 env,
21 begin_time,
22 end_time,
23 log_id_cursor,
24 biz_group_id,
25 biz_sub_group_id,
26 in_out,
27 currency,
28 symbol,
29 stock_id,
30 max_cnt,
31 keyword,
32 } = args;
33 let acc_id = cmd::account::resolve_account_locator(
35 gateway,
36 acc_id_pos.or(acc_id),
37 acc_id_file.as_deref(),
38 card_num.as_deref(),
39 "cash-log",
40 )
41 .await?;
42 cmd::tier_m::run_cash_log(cmd::tier_m::CashLogCommand {
43 gateway,
44 env: &env,
45 acc_id,
46 begin_time,
47 end_time,
48 log_id_cursor,
49 biz_group_id,
50 biz_sub_group_id,
51 in_out,
52 keyword,
53 symbol,
54 stock_id,
55 max_cnt,
56 currency,
57 format: output,
58 })
59 .await
60}
61
62pub(super) async fn dispatch_cash_detail(
63 gateway: &str,
64 output: OutputFormat,
65 args: CashDetailArgs,
66) -> Result<()> {
67 let CashDetailArgs {
68 acc_id_pos,
69 acc_id,
70 card_num,
71 acc_id_file,
72 env,
73 log_id,
74 } = args;
75 let acc_id = cmd::account::resolve_account_locator(
76 gateway,
77 acc_id_pos.or(acc_id),
78 acc_id_file.as_deref(),
79 card_num.as_deref(),
80 "cash-detail",
81 )
82 .await?;
83 cmd::tier_m::run_cash_detail(gateway, &env, acc_id, log_id, output).await
84}
85
86pub(super) async fn dispatch_biz_group(
87 gateway: &str,
88 output: OutputFormat,
89 args: BizGroupArgs,
90) -> Result<()> {
91 let BizGroupArgs {
92 acc_id_pos,
93 acc_id,
94 card_num,
95 acc_id_file,
96 env,
97 } = args;
98 let acc_id = cmd::account::resolve_account_locator(
99 gateway,
100 acc_id_pos.or(acc_id),
101 acc_id_file.as_deref(),
102 card_num.as_deref(),
103 "biz-group",
104 )
105 .await?;
106 cmd::tier_m::run_biz_group(gateway, &env, acc_id, output).await
107}
108
109pub(super) async fn dispatch_margin_info(
110 gateway: &str,
111 output: OutputFormat,
112 args: MarginInfoArgs,
113) -> Result<()> {
114 let MarginInfoArgs {
115 acc_id_pos,
116 acc_id,
117 card_num,
118 acc_id_file,
119 env,
120 market,
121 } = args;
122 let acc_id = cmd::account::resolve_account_locator(
123 gateway,
124 acc_id_pos.or(acc_id),
125 acc_id_file.as_deref(),
126 card_num.as_deref(),
127 "margin-info",
128 )
129 .await?;
130 cmd::tier_m::run_margin_info(gateway, &env, acc_id, &market, output).await
131}
132
133pub(super) async fn dispatch_account_flag(
134 gateway: &str,
135 output: OutputFormat,
136 args: AccountFlagArgs,
137) -> Result<()> {
138 let AccountFlagArgs {
139 acc_id,
140 card_num,
141 acc_id_file,
142 env,
143 flag_id,
144 } = args;
145 let acc_id = cmd::account::resolve_account_locator(
146 gateway,
147 acc_id,
148 acc_id_file.as_deref(),
149 card_num.as_deref(),
150 "account-flag",
151 )
152 .await?;
153 cmd::tier_m::run_account_flag(gateway, &env, acc_id, flag_id, output).await
154}
155
156pub(super) async fn dispatch_bond_total_asset(
157 gateway: &str,
158 output: OutputFormat,
159 args: BondTotalAssetArgs,
160) -> Result<()> {
161 let BondTotalAssetArgs {
162 acc_id,
163 card_num,
164 acc_id_file,
165 env,
166 market,
167 } = args;
168 let acc_id = cmd::account::resolve_account_locator(
169 gateway,
170 acc_id,
171 acc_id_file.as_deref(),
172 card_num.as_deref(),
173 "bond-total-asset",
174 )
175 .await?;
176 cmd::tier_m::run_bond_total_asset(gateway, &env, acc_id, &market, output).await
177}
178
179pub(super) async fn dispatch_bond_single_asset(
180 gateway: &str,
181 output: OutputFormat,
182 args: BondSingleAssetArgs,
183) -> Result<()> {
184 let BondSingleAssetArgs {
185 acc_id,
186 card_num,
187 acc_id_file,
188 env,
189 market,
190 symbol,
191 } = args;
192 let acc_id = cmd::account::resolve_account_locator(
193 gateway,
194 acc_id,
195 acc_id_file.as_deref(),
196 card_num.as_deref(),
197 "bond-single-asset",
198 )
199 .await?;
200 cmd::tier_m::run_bond_single_asset(gateway, &env, acc_id, &market, &symbol, output).await
201}
202
203pub(super) async fn dispatch_bond_position_list(
204 gateway: &str,
205 output: OutputFormat,
206 args: BondPositionListArgs,
207) -> Result<()> {
208 let BondPositionListArgs {
209 acc_id,
210 card_num,
211 acc_id_file,
212 env,
213 market,
214 } = args;
215 let acc_id = cmd::account::resolve_account_locator(
216 gateway,
217 acc_id,
218 acc_id_file.as_deref(),
219 card_num.as_deref(),
220 "bond-position-list",
221 )
222 .await?;
223 cmd::tier_m::run_bond_position_list(gateway, &env, acc_id, &market, output).await
224}
225
226pub(super) async fn dispatch_bond_answer_state(
227 gateway: &str,
228 output: OutputFormat,
229 args: BondAnswerStateArgs,
230) -> Result<()> {
231 let BondAnswerStateArgs {
232 acc_id,
233 card_num,
234 acc_id_file,
235 env,
236 market,
237 symbol,
238 } = args;
239 let acc_id = cmd::account::resolve_account_locator(
240 gateway,
241 acc_id,
242 acc_id_file.as_deref(),
243 card_num.as_deref(),
244 "bond-answer-state",
245 )
246 .await?;
247 cmd::tier_m::run_bond_answer_state(gateway, &env, acc_id, &market, &symbol, output).await
248}
249
250pub(super) async fn dispatch_bond_trade_reminder(
251 gateway: &str,
252 output: OutputFormat,
253 args: BondTradeReminderArgs,
254) -> Result<()> {
255 let BondTradeReminderArgs {
256 acc_id,
257 card_num,
258 acc_id_file,
259 env,
260 market,
261 symbol,
262 } = args;
263 let acc_id = cmd::account::resolve_account_locator(
264 gateway,
265 acc_id,
266 acc_id_file.as_deref(),
267 card_num.as_deref(),
268 "bond-trade-reminder",
269 )
270 .await?;
271 cmd::tier_m::run_bond_trade_reminder(gateway, &env, acc_id, &market, &symbol, output).await
272}