1
//! The balance report's reader: an empty `as-of` is today, which the form then shows.
2

            
3
use forms::REPORT_BALANCE;
4
use rpc::forms::Outcome;
5
use server::command::ReportData;
6
use uuid::Uuid;
7

            
8
use super::query::{Asked, ask_form};
9
use crate::response::WebError;
10

            
11
25
pub async fn ask(
12
25
    user_id: Uuid,
13
25
    pairs: Vec<(String, String)>,
14
25
) -> Result<Asked<ReportData>, WebError> {
15
25
    ask_form(user_id, pairs, &REPORT_BALANCE, pick).await
16
25
}
17

            
18
19
fn pick(outcome: Outcome) -> Option<ReportData> {
19
19
    match outcome {
20
19
        Outcome::Balance(data) => Some(data),
21
        _ => None,
22
    }
23
19
}