advotracker-framework: Rename 'frontend' to advotracker
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "advotracker_frontend"
|
name = "advotracker"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
|
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
|
||||||
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
|
description = "Frontend component that supports lawyers to capture relevant data encountered during an online legal advice."
|
||||||
@@ -20,7 +20,7 @@ dotenv = "~0.15.0"
|
|||||||
#env_logger = "~0.7.1"
|
#env_logger = "~0.7.1"
|
||||||
envy = { version = "~0.4" }
|
envy = { version = "~0.4" }
|
||||||
log = "~0.4.8"
|
log = "~0.4.8"
|
||||||
locales = { version = "0.1" }
|
locales = { version = "~0.1" }
|
||||||
#orbtk = "~0.3.1-alpha3"
|
#orbtk = "~0.3.1-alpha3"
|
||||||
#orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
|
#orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
|
||||||
orbtk = { path = "../../redox-os/orbtk" }
|
orbtk = { path = "../../redox-os/orbtk" }
|
||||||
@@ -36,7 +36,7 @@ viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cach
|
|||||||
default = ["orbtk/debug"]
|
default = ["orbtk/debug"]
|
||||||
|
|
||||||
[package.metadata.bundle]
|
[package.metadata.bundle]
|
||||||
name = "AdvoTracker"
|
name = "advotracker"
|
||||||
identifier = "rzerres.advotracker"
|
identifier = "rzerres.advotracker"
|
||||||
short_description = "Task app based on OrbTk."
|
short_description = "Task app based on OrbTk."
|
||||||
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"
|
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"
|
||||||
@@ -7,12 +7,13 @@
|
|||||||
|
|
||||||
use chrono::{Local, DateTime};
|
use chrono::{Local, DateTime};
|
||||||
use locales::t;
|
use locales::t;
|
||||||
|
//use serde::{Deserialize, Serialize};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::{error::Error, process};
|
use std::{error::Error, process};
|
||||||
use tracing::{debug, trace, Level};
|
use tracing::{debug, trace, Level};
|
||||||
|
|
||||||
//use crate::db::data::CsvImportRecord;
|
use advotracker::data::{PolicyList, PolicyDataList, PolicyData};
|
||||||
|
|
||||||
// include modules
|
// include modules
|
||||||
mod parse_args;
|
mod parse_args;
|
||||||
@@ -26,32 +27,23 @@ struct Environment {
|
|||||||
log: String,
|
log: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
|
||||||
pub struct CsvImportRecord {
|
|
||||||
// dion => Allianz Dion: 1-9
|
|
||||||
// policy_code => Policy Typ: "AS"
|
|
||||||
// policy_number => Versicherungsscheinnummer: "1515735810"
|
|
||||||
pub dion: String,
|
|
||||||
pub policy_code: String,
|
|
||||||
pub policy_number: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug, Deserialize)]
|
|
||||||
pub struct RecordList {
|
|
||||||
records: Vec<CsvImportRecord>
|
|
||||||
}
|
|
||||||
|
|
||||||
/// export as csv format
|
/// export as csv format
|
||||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||||
/// https://blog.burntsushi.net/csv/
|
/// https://blog.burntsushi.net/csv/
|
||||||
fn export(p: &mut String, lang: &String) -> Result<(), Box<dyn Error>> {
|
fn export(p: &mut String, lang: &String) -> Result<usize, Box<dyn Error>> {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
//use std::ffi::OsStr;
|
//use std::ffi::OsStr;
|
||||||
|
use std::io::prelude::*;
|
||||||
|
|
||||||
let mut res = t!("csv_import.started", lang);
|
let mut res = t!("csv_export.started", lang);
|
||||||
let mut state = t!("state.started", lang);
|
let mut state = t!("state.started", lang);
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
let dt_start: DateTime<Local> = Local::now();
|
||||||
|
|
||||||
|
trace!(target: "csv-test",
|
||||||
|
process = ?res,
|
||||||
|
state = ?state,
|
||||||
|
date_start = ?dt_start.to_string());
|
||||||
|
|
||||||
// Note: slash syntax also works on Windows!
|
// Note: slash syntax also works on Windows!
|
||||||
let path = Path::new(p);
|
let path = Path::new(p);
|
||||||
@@ -64,21 +56,32 @@ fn export(p: &mut String, lang: &String) -> Result<(), Box<dyn Error>> {
|
|||||||
// _ => println!("got file extension {:?}", extension)
|
// _ => println!("got file extension {:?}", extension)
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// open the file
|
// open the file descriptor
|
||||||
let file = File::open(path)?;
|
let mut file = File::create(path)?;
|
||||||
|
|
||||||
trace!(target: "csv-export", extension = ?path.extension(), file = ?file);
|
trace!(target: "csv-export", extension = ?path.extension(), file = ?file);
|
||||||
|
|
||||||
|
// Build the CSV writer and push selected records.
|
||||||
|
//for result in csv_reader.records() {
|
||||||
|
let mut count = 0;
|
||||||
|
file.write_all(b"Allianz DirectCall Protokoll!")?;
|
||||||
|
count += 1;
|
||||||
|
|
||||||
|
let dt_end: DateTime<Local> = Local::now();
|
||||||
|
let duration = dt_end.signed_duration_since(dt_start);
|
||||||
|
println!("Duration: {:#?}", duration);
|
||||||
|
|
||||||
|
trace!(target: "csv-test", record_count = ?count, duration = ?duration);
|
||||||
state = t!("state.finished", lang);
|
state = t!("state.finished", lang);
|
||||||
res = t!("csv_import.finished", lang);
|
res = t!("csv_import.finished", lang);
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||||
|
|
||||||
Ok(())
|
Ok(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// import from csv format
|
/// import from csv format
|
||||||
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
|
||||||
/// https://blog.burntsushi.net/csv/
|
/// https://blog.burntsushi.net/csv/
|
||||||
fn import(p: &mut String, lang: &String) -> Result<u32, Box<dyn Error>> {
|
fn import(p: &mut String, data_list: &mut PolicyDataList, lang: &String) -> Result<usize, Box<dyn Error>> {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
@@ -87,13 +90,20 @@ fn import(p: &mut String, lang: &String) -> Result<u32, Box<dyn Error>> {
|
|||||||
let mut state = t!("state.started", lang);
|
let mut state = t!("state.started", lang);
|
||||||
let dt_start: DateTime<Local> = Local::now();
|
let dt_start: DateTime<Local> = Local::now();
|
||||||
|
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state, date_start = ?dt_start.to_string());
|
trace!(target: "csv-test",
|
||||||
|
process = ?res,
|
||||||
|
state = ?state,
|
||||||
|
date_start = ?dt_start.to_string());
|
||||||
|
|
||||||
// Note: slash syntax also workd on Windows!
|
// Note: slash syntax also workd on Windows!
|
||||||
let path = Path::new(p);
|
let path = Path::new(p);
|
||||||
|
|
||||||
// must be a readable file
|
// must be a readable file
|
||||||
trace!(target: "csv-test", path = ?path);
|
trace!(target: "csv-test", path = ?path);
|
||||||
|
let valid = path.is_file();
|
||||||
|
println!("is_file: {}", valid);
|
||||||
|
|
||||||
|
//if let Some(res) = valid
|
||||||
assert_eq!(path.is_file(), true);
|
assert_eq!(path.is_file(), true);
|
||||||
|
|
||||||
// only accept files with '.txt' extensions
|
// only accept files with '.txt' extensions
|
||||||
@@ -102,14 +112,18 @@ fn import(p: &mut String, lang: &String) -> Result<u32, Box<dyn Error>> {
|
|||||||
|
|
||||||
// open the file
|
// open the file
|
||||||
let file = File::open(path)?;
|
let file = File::open(path)?;
|
||||||
trace!(target: "csv-test", extension = ?extension, file = ?file);
|
|
||||||
|
trace!(target: "csv-test",
|
||||||
|
extension = ?extension,
|
||||||
|
file = ?file,
|
||||||
|
data_list = ?data_list.name);
|
||||||
|
|
||||||
// Build the CSV reader and iterate over each record.
|
// Build the CSV reader and iterate over each record.
|
||||||
let mut csv_reader = csv::ReaderBuilder::new()
|
let mut csv_reader = csv::ReaderBuilder::new()
|
||||||
.has_headers(false)
|
.has_headers(true)
|
||||||
.delimiter(b' ')
|
.delimiter(b' ')
|
||||||
.comment(Some(b'#'))
|
.flexible(true)
|
||||||
//.has_headers(true)
|
//.comment(Some(b'#'))
|
||||||
//.from_reader(io::stdin());
|
//.from_reader(io::stdin());
|
||||||
//.from_path(path);
|
//.from_path(path);
|
||||||
.from_reader(file);
|
.from_reader(file);
|
||||||
@@ -118,14 +132,19 @@ fn import(p: &mut String, lang: &String) -> Result<u32, Box<dyn Error>> {
|
|||||||
let headers = csv_reader.headers()?;
|
let headers = csv_reader.headers()?;
|
||||||
trace!(target: "csv-test", header = ?headers);
|
trace!(target: "csv-test", header = ?headers);
|
||||||
}
|
}
|
||||||
//for result in csv_reader.records() {
|
|
||||||
|
// Deserialize the input data and push result to target vector
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
for result in csv_reader.deserialize() {
|
for result in csv_reader.deserialize() {
|
||||||
// The iterator yields Result<StringRecord, Error>, so we check the
|
// The iterator yields Result<StringRecord, Error>, so we check the
|
||||||
// error here.
|
// error here.
|
||||||
//let record = result?;
|
let record: PolicyData = result?;
|
||||||
let _record: CsvImportRecord = result?;
|
println!("{:?}", record);
|
||||||
//println!("{:?}", record);
|
|
||||||
|
// WIP: write to redis backend
|
||||||
|
// push record as new vector elements
|
||||||
|
data_list.push(record);
|
||||||
|
|
||||||
count +=1;
|
count +=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,12 +157,56 @@ fn import(p: &mut String, lang: &String) -> Result<u32, Box<dyn Error>> {
|
|||||||
|
|
||||||
state = t!("state.finished", lang);
|
state = t!("state.finished", lang);
|
||||||
res = t!("csv_import.finished", lang);
|
res = t!("csv_import.finished", lang);
|
||||||
trace!(target: "csv-test", process = ?res, state = ?state, date_stop = ?dt_end.to_string());
|
trace!(target: "csv-test",
|
||||||
|
process = ?res,
|
||||||
|
state = ?state,
|
||||||
|
date_stop = ?dt_end.to_string());
|
||||||
|
|
||||||
//Ok(count, duration.seconds())
|
//Ok(count, duration.seconds())
|
||||||
Ok(count)
|
Ok(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// validate a given policy number
|
||||||
|
/// result will return true or false
|
||||||
|
fn is_valid(policy_number: &usize, policy_list: &PolicyDataList, lang: &String) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
||||||
|
let mut res = t!("policy.validation.started", lang);
|
||||||
|
let mut state = t!("state.started", lang);
|
||||||
|
let dt_start: DateTime<Local> = Local::now();
|
||||||
|
|
||||||
|
trace!(target: "csv-test",
|
||||||
|
process = ?res,
|
||||||
|
state = ?state,
|
||||||
|
policy_number = ?policy_number,
|
||||||
|
policy_list = ?policy_list.name,
|
||||||
|
elements = ?policy_list.policy_data.len(),
|
||||||
|
date_start = ?dt_start.to_string());
|
||||||
|
|
||||||
|
// println!("policy_number: {:?}", policy_number);
|
||||||
|
// println!("policy_list: {:?} (with {:?} elements)",
|
||||||
|
// policy_list.name, policy_list.policy_data.len());
|
||||||
|
|
||||||
|
let test: Vec<_> = vec!["one", "two", "three"];
|
||||||
|
let index: usize = test.iter().enumerate().find(|&r| r.1.to_string() == "two".to_string()).unwrap().0;
|
||||||
|
println!("index: {:?} -> {:?}", index, test[index]);
|
||||||
|
|
||||||
|
//let index: usize = test.iter().enumerate().find(|&r| r.policy_number == "two".to_string()).unwrap().0;
|
||||||
|
|
||||||
|
let dt_end: DateTime<Local> = Local::now();
|
||||||
|
let duration = dt_end.signed_duration_since(dt_start);
|
||||||
|
|
||||||
|
res = t!("policy.validation.finished", lang);
|
||||||
|
state = t!("state.finished", lang);
|
||||||
|
trace!(target: "csv-test",
|
||||||
|
process = ?res,
|
||||||
|
state = ?state,
|
||||||
|
date_stop = ?dt_end.to_string());
|
||||||
|
|
||||||
|
trace!(target: "csv-test", duration = ?duration);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use parse_args::parse_args;
|
use parse_args::parse_args;
|
||||||
@@ -210,8 +273,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
trace!(target: "csv-test", process = ?res, state = ?state);
|
trace!(target: "csv-test", process = ?res, state = ?state);
|
||||||
|
|
||||||
// importing policy code elements from csv-file
|
// importing policy code elements from csv-file
|
||||||
|
let policy_list = PolicyList::new("Allianz Versicherungsnummen-List");
|
||||||
|
println!("Policy List {:?} ", policy_list.name);
|
||||||
|
|
||||||
|
let mut policy_data = PolicyDataList::new("Allianz-Import 20200628");
|
||||||
|
println!("Policy Data List {:?} ", policy_data.name);
|
||||||
|
|
||||||
let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||||
match import(&mut csv_import_path, &lang) {
|
match import(&mut csv_import_path, &mut policy_data, &lang) {
|
||||||
Ok(count) => {
|
Ok(count) => {
|
||||||
println!("Imported {:?} records", count);
|
println!("Imported {:?} records", count);
|
||||||
}
|
}
|
||||||
@@ -221,6 +290,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test if policy_number is_valid
|
||||||
|
let policy_number : usize = 9999999999;
|
||||||
|
let _res = is_valid(&policy_number, &policy_data, &lang);
|
||||||
|
println!("given policy_number {:?} is valid!", policy_number);
|
||||||
|
|
||||||
// export policy code elements to csv-file
|
// export policy code elements to csv-file
|
||||||
let mut csv_export_path = v.get::<String>("export_file").unwrap();
|
let mut csv_export_path = v.get::<String>("export_file").unwrap();
|
||||||
match export(&mut csv_export_path, &lang) {
|
match export(&mut csv_export_path, &lang) {
|
||||||
@@ -19,7 +19,8 @@ pub fn parse_args(v: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
// preset default key/value pairs (lowest priority)
|
// preset default key/value pairs (lowest priority)
|
||||||
v.add_default("config_file", String::from("csv_import.ron"));
|
v.add_default("config_file", String::from("csv_import.ron"));
|
||||||
v.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
//v.add_default("import_file", String::from("POLLFNR_WOECHENTLICH.txt"));
|
||||||
|
v.add_default("import_file", String::from("POLLFNR_TEST.txt"));
|
||||||
v.add_default("export_file", String::from(""));
|
v.add_default("export_file", String::from(""));
|
||||||
v.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
v.add_default("to_email_address_file", String::from("Allianz RA-Hotline <smr-rahotline@allianz.de>"));
|
||||||
v.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
|
v.add_default("from_email_address_file", String::from("Allianz-Hotline RA-Hiedemann <azhotline@hiedemann.de>"));
|
||||||
@@ -63,8 +64,9 @@ SMR Unerledigt: 089 92529 60222")
|
|||||||
.short("i")
|
.short("i")
|
||||||
.long("importFile")
|
.long("importFile")
|
||||||
.help("Select source file for the csv-import")
|
.help("Select source file for the csv-import")
|
||||||
.default_value("POLLFNR_WOECHENTLICH.txt")
|
//.default_value("POLLFNR_WOECHENTLICH.txt")
|
||||||
.takes_value(true),
|
.default_value("POLLFNR_TEST.txt")
|
||||||
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("exportFile")
|
Arg::with_name("exportFile")
|
||||||
|
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 123 B After Width: | Height: | Size: 123 B |
|
Before Width: | Height: | Size: 289 B After Width: | Height: | Size: 289 B |
|
Before Width: | Height: | Size: 126 B After Width: | Height: | Size: 126 B |
|
Before Width: | Height: | Size: 158 B After Width: | Height: | Size: 158 B |
|
Before Width: | Height: | Size: 351 B After Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 193 B After Width: | Height: | Size: 193 B |
|
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 223 B |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 768 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 455 KiB After Width: | Height: | Size: 455 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 237 KiB After Width: | Height: | Size: 237 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 237 KiB After Width: | Height: | Size: 237 KiB |
@@ -1,12 +1,18 @@
|
|||||||
use orbtk::prelude::*;
|
/*
|
||||||
|
* advotracker - Hotline tackingtool for Advocats
|
||||||
|
*
|
||||||
|
* Copyright 2020 Ralf Zerres <ralf.zerres@networkx.de>
|
||||||
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
|
*/
|
||||||
|
|
||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// An enumeration of valid policy codes
|
/// An enumeration of valid policy codes.
|
||||||
/// right now, only "AS" is used
|
/// right now, only "AS" is used.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub enum PolicyCode {
|
pub enum PolicyCode {
|
||||||
|
/// Allianz Sachversicherung
|
||||||
AS
|
AS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,10 +20,56 @@ impl Default for PolicyCode {
|
|||||||
fn default() -> Self { PolicyCode::AS }
|
fn default() -> Self { PolicyCode::AS }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Status of a given policy data element (eg: active / inactive)
|
/// Classifier of the Allinaz DirectCall communication type.
|
||||||
|
pub enum CommunicationType {
|
||||||
|
/// Anhörung
|
||||||
|
A,
|
||||||
|
/// Bußgeldbescheid
|
||||||
|
BU,
|
||||||
|
/// Gdb
|
||||||
|
Gdb,
|
||||||
|
/// Geburt
|
||||||
|
GE,
|
||||||
|
/// Hochzeit
|
||||||
|
HO,
|
||||||
|
/// Kündigung
|
||||||
|
KD,
|
||||||
|
/// Kaufvertrag
|
||||||
|
KV,
|
||||||
|
/// Lohn
|
||||||
|
LO,
|
||||||
|
/// Nachbar
|
||||||
|
NA,
|
||||||
|
/// Rente
|
||||||
|
RE,
|
||||||
|
/// Unfallflucht
|
||||||
|
UF,
|
||||||
|
/// Unterhalt
|
||||||
|
UH,
|
||||||
|
/// Unfall
|
||||||
|
UN,
|
||||||
|
/// Vodafone
|
||||||
|
VF,
|
||||||
|
/// Vermieter
|
||||||
|
VM,
|
||||||
|
/// Verwaltungsrecht
|
||||||
|
VW,
|
||||||
|
/// Zeugins
|
||||||
|
ZE,
|
||||||
|
/// Typ is unspecified
|
||||||
|
XX
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CommunicationType {
|
||||||
|
fn default() -> Self { CommunicationType::XX }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Status of a given policy data element.
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub enum Status {
|
pub enum Status {
|
||||||
|
/// Active -> the policy is active an supported
|
||||||
Active,
|
Active,
|
||||||
|
/// Inactive -> the policy is inactive or resigned
|
||||||
Inactive
|
Inactive
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,54 +78,43 @@ impl Default for Status {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A communication type describes possible classifications of customer calls.
|
/// A communication type describes possible classifications of customer calls.
|
||||||
/// If not selected, the default will be 'unclassified'.
|
/// If the type isn't selected, the default will be 'unclassified -> XX'.
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Deserialize, Serialize)]
|
||||||
pub struct CommunicationType {
|
pub struct CommunicationData {
|
||||||
// Unfall, Bußgeldbescheid, Anhörung, Unfallflucht, Kaufvertrag,
|
/// pub communication_type: CommunicationType,
|
||||||
// Vodafone, Kündigung, Lohn, Zeugnis, Nachbar, Vermieter, Rente, GdB, Verwaltungsrecht, Unterhalt, Geburt, Hochzeit
|
pub communication_type: String,
|
||||||
pub communication_id: String,
|
/// A literal name describing the selected communication type
|
||||||
pub communication_name: String,
|
pub communication_name: String
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CSV Export
|
/// CSV Export
|
||||||
/// The structure elements are required for an export to a comma seperated text list.
|
/// The structure elements are required for an export to a comma seperated text list.
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct CsvExportRecord {
|
pub struct CsvExportRecord {
|
||||||
// policy_code => Versicherungsscheinnummer: "AS1234567890"
|
/// Versicherungsschein Code
|
||||||
// policy_holder => Anrufer: "Vorname, Nachname"
|
|
||||||
// facts => Sachverhalt: "Kurzschilderung"
|
|
||||||
// harm_type => Schadensart: "harm_name (harm_id)"
|
|
||||||
// communication_type => Kommunikationszeichen: "(communication_name)"
|
|
||||||
// ra_hotline => RA_Hotline: Kanzlei Laqua, Kanzlei Buschbell, Kanzlei DAH, Kanzlei Hiedemann
|
|
||||||
// ivr_comment => Haftungs-/Deckungskommentar; #IVR (ggf. ergänzt um das Beratungsergebnis)
|
|
||||||
pub policy_code: String,
|
pub policy_code: String,
|
||||||
|
/// Versicherungsscheinnummer (10-stellig, numerisch)
|
||||||
pub policy_number: u32,
|
pub policy_number: u32,
|
||||||
|
/// Anrufer: "Vorname, Nachname"
|
||||||
pub policy_holder: String,
|
pub policy_holder: String,
|
||||||
|
/// Sachverhalt: "Kurzschilderung"
|
||||||
pub facts: String,
|
pub facts: String,
|
||||||
|
/// Schadensart: "harm_name (harm_id)"
|
||||||
pub harm_type: String,
|
pub harm_type: String,
|
||||||
|
/// communication_type => Kommunikationszeichen: "(communication_name)"
|
||||||
pub communication_name: String,
|
pub communication_name: String,
|
||||||
|
/// ra_hotline => RA_Hotline: Kanzlei Laqua, Kanzlei Buschbell, Kanzlei DAH, Kanzlei Hiedemann
|
||||||
pub ra_hotline: String, // const "Kanzlei Hiedemann",
|
pub ra_hotline: String, // const "Kanzlei Hiedemann",
|
||||||
|
/// ivr_comment => Haftungs-/Deckungskommentar; #IVR (ggf. ergänzt um das Beratungsergebnis)
|
||||||
pub ivr_comment: String,
|
pub ivr_comment: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CSV Import
|
|
||||||
/// The structure elements provided as a comma seperated text list.
|
|
||||||
/// Referenz: ERG.txt -> 'DION VERS POLLFNR'
|
|
||||||
/// '1 AS 1515735810'
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
|
||||||
pub struct CsvImportRecord {
|
|
||||||
// dion => Allianz Dion: 1
|
|
||||||
// policy_code => Policy Typ: "AS"
|
|
||||||
// policy_number => Versicherungsscheinnummer: "1515735810"
|
|
||||||
pub dion: String,
|
|
||||||
pub policy_code: String,
|
|
||||||
pub policy_number: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Harm data are list/collections of harm types. You may toggle them to an unselected state.
|
/// Harm data are list/collections of harm types. You may toggle them to an unselected state.
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct HarmData {
|
pub struct HarmData {
|
||||||
|
/// Liste der Schadensdaten
|
||||||
pub harm_data: Vec<HarmType>,
|
pub harm_data: Vec<HarmType>,
|
||||||
|
/// Status der Schadenliste
|
||||||
//pub name: String,
|
//pub name: String,
|
||||||
pub selected: bool
|
pub selected: bool
|
||||||
}
|
}
|
||||||
@@ -82,6 +123,7 @@ pub struct HarmData {
|
|||||||
/// The type code represents the unique harm identifier, bound with a literal name.
|
/// The type code represents the unique harm identifier, bound with a literal name.
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct HarmType {
|
pub struct HarmType {
|
||||||
|
/// Kennzeichen des Schadenstyps
|
||||||
// Schadenersatz-RS im Verkehrsbereich (RS112)
|
// Schadenersatz-RS im Verkehrsbereich (RS112)
|
||||||
// Ordnungswidrigkeits-RS im Verkehrsbereich (RS122)
|
// Ordnungswidrigkeits-RS im Verkehrsbereich (RS122)
|
||||||
// Straf-RS im Verkehrsbereich (RS121)
|
// Straf-RS im Verkehrsbereich (RS121)
|
||||||
@@ -93,14 +135,18 @@ pub struct HarmType {
|
|||||||
// Rechtsschutz im Familien- und Erbrecht (RS217)
|
// Rechtsschutz im Familien- und Erbrecht (RS217)
|
||||||
// Wagnis nicht versicherbar / versichert (RS999)
|
// Wagnis nicht versicherbar / versichert (RS999)
|
||||||
pub harm_type: String,
|
pub harm_type: String,
|
||||||
|
/// Beschreibung des Schadenstyps
|
||||||
pub harm_name: String,
|
pub harm_name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structure used to verify a policy data element.
|
/// Structure used to verify a policy data element.
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct PolicyCheck {
|
pub struct PolicyCheck {
|
||||||
|
/// Versicherungsschein-Prüfnummer
|
||||||
pub policy_check_number: String,
|
pub policy_check_number: String,
|
||||||
|
/// Referenz zur Versicherungsschein-Nummer
|
||||||
pub policy_number: String,
|
pub policy_number: String,
|
||||||
|
/// Validitätsergebnis
|
||||||
pub policy_number_valid: bool
|
pub policy_number_valid: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,74 +167,99 @@ pub struct PolicyCheck {
|
|||||||
/// Structure collecting policy data elements
|
/// Structure collecting policy data elements
|
||||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct PolicyList {
|
pub struct PolicyList {
|
||||||
|
/// Bescheibung der Versicherungsdatenliste
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
/// Listenelemente der Versicherungsdatendaten
|
||||||
pub policy_list: Vec<PolicyDataList>,
|
pub policy_list: Vec<PolicyDataList>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// implements helper methods, that manage lists of policy data collections
|
/// implements helper methods, that manage lists of policy data collections
|
||||||
impl PolicyList {
|
impl PolicyList {
|
||||||
|
/// Index auf Versicherungsliste zurückgeben (unveränderbar)
|
||||||
pub fn get(&self, index: usize) -> Option<&PolicyDataList> {
|
pub fn get(&self, index: usize) -> Option<&PolicyDataList> {
|
||||||
self.policy_list.get(index)
|
self.policy_list.get(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Index auf Versicherungsliste zurückgeben (veränderbar)
|
||||||
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyDataList> {
|
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyDataList> {
|
||||||
self.policy_list.get_mut(index)
|
self.policy_list.get_mut(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Neuer Eintrag am Anfang der Liste einfügen.
|
||||||
pub fn insert_front(&mut self, policy_list: PolicyDataList) {
|
pub fn insert_front(&mut self, policy_list: PolicyDataList) {
|
||||||
self.policy_list.insert(0, policy_list);
|
self.policy_list.insert(0, policy_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Prüfung ob Versicherungsliste keine Elemente enthält.
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.policy_list.is_empty()
|
self.policy_list.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Berechnet die Anzahl der Versicherungslisten Elemente.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
self.policy_list.len()
|
self.policy_list.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Neuen Versicherungslisten-Namen erzeugen
|
||||||
pub fn new(name: impl Into<String>) -> Self {
|
pub fn new(name: impl Into<String>) -> Self {
|
||||||
PolicyList {
|
PolicyList {
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Element der Versicherungsliste anfügen
|
||||||
pub fn push(&mut self, policy_list: PolicyDataList) {
|
pub fn push(&mut self, policy_list: PolicyDataList) {
|
||||||
self.policy_list.push(policy_list);
|
self.policy_list.push(policy_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Element der Versicherungsliste löschen
|
||||||
pub fn remove(&mut self, index: usize) -> PolicyDataList {
|
pub fn remove(&mut self, index: usize) -> PolicyDataList {
|
||||||
self.policy_list.remove(index)
|
self.policy_list.remove(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Structure representing a policy data element
|
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
|
||||||
pub struct PolicyData {
|
|
||||||
// DION VERS POLLFNR
|
|
||||||
// 1 AS 1515735810
|
|
||||||
// DION: Allianz id => len = 1??
|
|
||||||
// VERS: policy_code => enum(AS; ??)
|
|
||||||
// POLLFNR: policy_number => len = 10
|
|
||||||
pub date_inserted: Option<NaiveDateTime>,
|
|
||||||
pub dion: u8,
|
|
||||||
// is String16 a better default-type?
|
|
||||||
pub policy_code: PolicyCode,
|
|
||||||
pub policy_number: u32,
|
|
||||||
pub status: Status
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Structure collects policy data elements.
|
/// Structure collects policy data elements.
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct PolicyDataList {
|
pub struct PolicyDataList {
|
||||||
|
/// Verfalldatum des Versicherungslisten Elements
|
||||||
pub date_valid_until: Option<NaiveDateTime>,
|
pub date_valid_until: Option<NaiveDateTime>,
|
||||||
|
/// Elemente des Versicherungsobjektes
|
||||||
pub policy_data: Vec<PolicyData>,
|
pub policy_data: Vec<PolicyData>,
|
||||||
|
/// Name der Versicherungsliste
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
/// Status der Versicherungsliste
|
||||||
pub selected: bool
|
pub selected: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
/// implements the helper methods, to manage policy data collections.
|
/// implements the helper methods, to manage policy data collections.
|
||||||
impl PolicyDataList {
|
impl PolicyDataList {
|
||||||
|
/// Prüfung ob Versicherungselemente .
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.policy_data.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Versicherungselement am Anfang anfügen
|
||||||
|
pub fn insert_front(&mut self, policy_data: PolicyData) {
|
||||||
|
self.policy_data.insert(0, policy_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Index zum Versicherungselement zurückgeben (unveränderbar)
|
||||||
|
pub fn get(&self, index: usize) -> Option<&PolicyData> {
|
||||||
|
self.policy_data.get(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Index zum Versicherungselement zurückgeben (veränderbar)
|
||||||
|
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyData> {
|
||||||
|
self.policy_data.get_mut(index)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Berechnet die Anzahl der Versicherungselemente.
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
self.policy_data.len()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Neues Versicherungselement erstellen.
|
||||||
pub fn new(name: impl Into<String>) -> Self {
|
pub fn new(name: impl Into<String>) -> Self {
|
||||||
// the new inserted element will be active by default
|
// the new inserted element will be active by default
|
||||||
PolicyDataList {
|
PolicyDataList {
|
||||||
@@ -199,35 +270,65 @@ impl PolicyDataList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Versicherungselement anfügen
|
||||||
pub fn push(&mut self, policy_data: PolicyData) {
|
pub fn push(&mut self, policy_data: PolicyData) {
|
||||||
self.policy_data.push(policy_data);
|
self.policy_data.push(policy_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_front(&mut self, policy_data: PolicyData) {
|
/// Versicherungselement löschen
|
||||||
self.policy_data.insert(0, policy_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn remove(&mut self, index: usize) -> PolicyData {
|
pub fn remove(&mut self, index: usize) -> PolicyData {
|
||||||
self.policy_data.remove(index)
|
self.policy_data.remove(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self, index: usize) -> Option<&PolicyData> {
|
|
||||||
self.policy_data.get(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyData> {
|
|
||||||
self.policy_data.get_mut(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn len(&self) -> usize {
|
|
||||||
self.policy_data.len()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
|
||||||
self.policy_data.is_empty()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
into_property_source!(PolicyCheck);
|
/// Structure representing a policy data element
|
||||||
into_property_source!(PolicyData);
|
/// This structure groups a set of fields that describes a policy number.
|
||||||
into_property_source!(PolicyList);
|
/// The data are regularily updated via a data import from a comma seperated
|
||||||
|
/// text file (csv file).
|
||||||
|
/// Since we parse the source record fields to rust types (serde deserialize)
|
||||||
|
/// the field order in our struct must meet the data field order in the source!
|
||||||
|
/// We do use field attribute to precisely rename the source fields (header names)
|
||||||
|
/// to our target rust field names.
|
||||||
|
/// Referenz: POLLFNR_WOECHENTLICH.txt ->
|
||||||
|
/// Header 'DION VERS POLLFNR'
|
||||||
|
/// Record '1 AS 1515735810'
|
||||||
|
// DION: Allianz id => len = 1??
|
||||||
|
// VERS: policy_code => enum(AS; ??)
|
||||||
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
|
pub struct PolicyData {
|
||||||
|
/// Erstellungsdatum
|
||||||
|
pub date_inserted: Option<NaiveDateTime>,
|
||||||
|
/// Allianz Dion
|
||||||
|
#[serde(rename = "DION")]
|
||||||
|
pub dion: u8,
|
||||||
|
/// Kennzeichen des Allianz Versicherungscodes
|
||||||
|
#[serde(rename = "VERS")]
|
||||||
|
pub policy_code: PolicyCode,
|
||||||
|
/// Versicherungsscheinnummer (10stellig, numerisch)
|
||||||
|
#[serde(rename = "POLLFNR")]
|
||||||
|
pub policy_number: usize,
|
||||||
|
/// Status des Versicherungsscheins
|
||||||
|
pub status: Option<Status>
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Policy Number Set
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub struct AllianzPolicyNumber {
|
||||||
|
/// Allianz Dion
|
||||||
|
#[serde(rename = "DION")]
|
||||||
|
pub dion: u8,
|
||||||
|
/// Kennzeichen des Allianz Versicherungstyps
|
||||||
|
#[serde(rename = "VERS")]
|
||||||
|
pub policy_code: String,
|
||||||
|
/// 10-stellige Versicherungsscheinnummer (numerisch)
|
||||||
|
#[serde(rename = "POLLFNR")]
|
||||||
|
pub policy_number: usize
|
||||||
|
}
|
||||||
|
|
||||||
|
// /// List of Allianz Policy Number records
|
||||||
|
// /// The structure elements are required for an export to a comma seperated text list.
|
||||||
|
// #[derive(Default, Debug, Deserialize)]
|
||||||
|
// pub struct AllianzPolicyNumberList {
|
||||||
|
// records: Vec<AllianzPolicyNumber>
|
||||||
|
// }
|
||||||
@@ -2,9 +2,11 @@ use orbtk::prelude::*;
|
|||||||
use orbtk::theme::DEFAULT_THEME_CSS;
|
use orbtk::theme::DEFAULT_THEME_CSS;
|
||||||
//use orbtk::theme::LIGHT_THEME_EXTENSION_CSS;
|
//use orbtk::theme::LIGHT_THEME_EXTENSION_CSS;
|
||||||
|
|
||||||
|
//use advotracker::services;
|
||||||
|
use advotracker::data;
|
||||||
|
|
||||||
// helper modules
|
// helper modules
|
||||||
pub mod base_state;
|
pub mod base_state;
|
||||||
pub mod data;
|
|
||||||
pub mod keys;
|
pub mod keys;
|
||||||
|
|
||||||
// the frontend
|
// the frontend
|
||||||