use chrono::NaiveDate; use std::collections::HashMap; use crate::model::income::{Create, Update}; use crate::validation::utils::*; pub fn create(form: &HashMap) -> Option { let month = parse::(form, "month")?; let year = parse::(form, "year")?; Some(Create { user_id: parse::(form, "user_id")?, amount: parse::(form, "amount")?, date: NaiveDate::from_ymd_opt(year, month, 1)?, }) } pub fn update(form: &HashMap) -> Option { let month = parse::(form, "month")?; let year = parse::(form, "year")?; Some(Update { user_id: parse::(form, "user_id")?, amount: parse::(form, "amount")?, date: NaiveDate::from_ymd_opt(year, month, 1)?, }) }