generated from OBJNULL/Dockerized-Rust
Added year support to formatter
This commit is contained in:
parent
0fd9c77c5c
commit
a140eb84a8
1 changed files with 7 additions and 1 deletions
|
@ -14,6 +14,7 @@ pub struct Parser {
|
||||||
mode: ParserModes,
|
mode: ParserModes,
|
||||||
paused: bool,
|
paused: bool,
|
||||||
|
|
||||||
|
year: String,
|
||||||
content: String,
|
content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ impl Parser {
|
||||||
mode: ParserModes::None,
|
mode: ParserModes::None,
|
||||||
paused: false,
|
paused: false,
|
||||||
|
|
||||||
|
year: String::new(),
|
||||||
content,
|
content,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +61,10 @@ impl Parser {
|
||||||
self.mode = ParserModes::Debit;
|
self.mode = ParserModes::Debit;
|
||||||
} else if line == "Deposits, credits and interest" {
|
} else if line == "Deposits, credits and interest" {
|
||||||
self.mode = ParserModes::Credit;
|
self.mode = ParserModes::Credit;
|
||||||
|
} else if line.contains("For") {
|
||||||
|
let mut parts = line.split('/').last().unwrap().split_whitespace();
|
||||||
|
let year_part = parts.nth(0).unwrap().to_string();
|
||||||
|
self.year = year_part;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn transaction(&mut self, t_type: ParserModes, line: &str) {
|
fn transaction(&mut self, t_type: ParserModes, line: &str) {
|
||||||
|
@ -73,7 +79,7 @@ impl Parser {
|
||||||
// Collecting based on Parts
|
// Collecting based on Parts
|
||||||
let description = parts[2..parts.len() - 1].join(" ");
|
let description = parts[2..parts.len() - 1].join(" ");
|
||||||
let mut amount: f64 = parts.last().unwrap().parse().unwrap_or(0.0);
|
let mut amount: f64 = parts.last().unwrap().parse().unwrap_or(0.0);
|
||||||
let date = parts[0].to_owned();
|
let date = format!("{}/{}", parts[0], &self.year);
|
||||||
|
|
||||||
// Is it a debit?
|
// Is it a debit?
|
||||||
match t_type {
|
match t_type {
|
||||||
|
|
Loading…
Reference in a new issue