|
@@ -5,7 +5,7 @@ use crate::receipt;
|
|
|
use crate::user::User;
|
|
use crate::user::User;
|
|
|
use chrono::{DateTime, Utc};
|
|
use chrono::{DateTime, Utc};
|
|
|
use qif_generator::{account::Account, split::Split, transaction::Transaction};
|
|
use qif_generator::{account::Account, split::Split, transaction::Transaction};
|
|
|
-use std::collections::HashMap;
|
|
|
|
|
|
|
+use std::collections::{HashMap, HashSet};
|
|
|
use std::fs;
|
|
use std::fs;
|
|
|
|
|
|
|
|
/// Read json file with receipt and convert it into `receipt::Purchase`
|
|
/// Read json file with receipt and convert it into `receipt::Purchase`
|
|
@@ -18,12 +18,12 @@ pub fn read_file(f: &str) -> receipt::Purchase {
|
|
|
pub fn gen_splits<F, C>(
|
|
pub fn gen_splits<F, C>(
|
|
|
items: &[receipt::Item],
|
|
items: &[receipt::Item],
|
|
|
cs: &mut CatStats,
|
|
cs: &mut CatStats,
|
|
|
- accounts: &[String],
|
|
|
|
|
|
|
+ accounts: &HashSet<String>,
|
|
|
filter: F,
|
|
filter: F,
|
|
|
categorizer: C,
|
|
categorizer: C,
|
|
|
) -> Vec<Split>
|
|
) -> Vec<Split>
|
|
|
where
|
|
where
|
|
|
- C: Fn(&str, &mut CatStats, &[String]) -> String,
|
|
|
|
|
|
|
+ C: Fn(&str, &mut CatStats, &HashSet<String>) -> String,
|
|
|
F: Fn(&str) -> &str,
|
|
F: Fn(&str) -> &str,
|
|
|
{
|
|
{
|
|
|
let mut result: Vec<Split> = Vec::new();
|
|
let mut result: Vec<Split> = Vec::new();
|
|
@@ -99,7 +99,7 @@ pub fn convert<'a, F, C>(
|
|
|
) -> Result<Transaction<'a>, String>
|
|
) -> Result<Transaction<'a>, String>
|
|
|
where
|
|
where
|
|
|
F: Fn(&str) -> &str,
|
|
F: Fn(&str) -> &str,
|
|
|
- C: Fn(&str, &mut CatStats, &[String]) -> String,
|
|
|
|
|
|
|
+ C: Fn(&str, &mut CatStats, &HashSet<String>) -> String,
|
|
|
{
|
|
{
|
|
|
let purchase = &read_file(filename);
|
|
let purchase = &read_file(filename);
|
|
|
let splits = &gen_splits(
|
|
let splits = &gen_splits(
|