advotracker-framework: Rename 'frontend' to advotracker

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-06-29 01:13:08 +02:00
parent 0582c1be43
commit b7e6d269dc
74 changed files with 292 additions and 113 deletions

View File

@@ -1,5 +1,5 @@
[package]
name = "advotracker_frontend"
name = "advotracker"
version = "0.1.0"
authors = ["Ralf Zerres <ralf.zerres@networkx.de>"]
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"
envy = { version = "~0.4" }
log = "~0.4.8"
locales = { version = "0.1" }
locales = { version = "~0.1" }
#orbtk = "~0.3.1-alpha3"
#orbtk = { git = "https://github.com/redox-os/orbtk.git", branch = "develop" }
orbtk = { path = "../../redox-os/orbtk" }
@@ -36,7 +36,7 @@ viperus = { git = "https://github.com/maurocordioli/viperus", features = ["cach
default = ["orbtk/debug"]
[package.metadata.bundle]
name = "AdvoTracker"
name = "advotracker"
identifier = "rzerres.advotracker"
short_description = "Task app based on OrbTk."
description = "Supports lawyers to capture relevant data encountered during an online legal advice.\n"

View File

@@ -7,12 +7,13 @@
use chrono::{Local, DateTime};
use locales::t;
//use serde::{Deserialize, Serialize};
use serde::Deserialize;
use std::env;
use std::{error::Error, process};
use tracing::{debug, trace, Level};
//use crate::db::data::CsvImportRecord;
use advotracker::data::{PolicyList, PolicyDataList, PolicyData};
// include modules
mod parse_args;
@@ -26,32 +27,23 @@ struct Environment {
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
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
/// 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::path::Path;
//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);
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!
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)
// };
// open the file
let file = File::open(path)?;
// open the file descriptor
let mut file = File::create(path)?;
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);
res = t!("csv_import.finished", lang);
trace!(target: "csv-test", process = ?res, state = ?state);
Ok(())
Ok(count)
}
/// import from csv format
/// https://docs.rs/csv/1.1.3/csv/cookbook/index.html
/// 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::path::Path;
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 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!
let path = Path::new(p);
// must be a readable file
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);
// 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
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.
let mut csv_reader = csv::ReaderBuilder::new()
.has_headers(false)
.has_headers(true)
.delimiter(b' ')
.comment(Some(b'#'))
//.has_headers(true)
.flexible(true)
//.comment(Some(b'#'))
//.from_reader(io::stdin());
//.from_path(path);
.from_reader(file);
@@ -118,14 +132,19 @@ fn import(p: &mut String, lang: &String) -> Result<u32, Box<dyn Error>> {
let headers = csv_reader.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;
for result in csv_reader.deserialize() {
// The iterator yields Result<StringRecord, Error>, so we check the
// error here.
//let record = result?;
let _record: CsvImportRecord = result?;
//println!("{:?}", record);
let record: PolicyData = result?;
println!("{:?}", record);
// WIP: write to redis backend
// push record as new vector elements
data_list.push(record);
count +=1;
}
@@ -138,12 +157,56 @@ fn import(p: &mut String, lang: &String) -> Result<u32, Box<dyn Error>> {
state = t!("state.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)
}
/// 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>> {
use dotenv::dotenv;
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);
// 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();
match import(&mut csv_import_path, &lang) {
match import(&mut csv_import_path, &mut policy_data, &lang) {
Ok(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
let mut csv_export_path = v.get::<String>("export_file").unwrap();
match export(&mut csv_export_path, &lang) {

View File

@@ -19,7 +19,8 @@ pub fn parse_args(v: &mut Viperus) -> Result<(), Box<dyn std::error::Error>> {
// preset default key/value pairs (lowest priority)
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("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>"));
@@ -63,7 +64,8 @@ SMR Unerledigt: 089 92529 60222")
.short("i")
.long("importFile")
.help("Select source file for the csv-import")
.default_value("POLLFNR_WOECHENTLICH.txt")
//.default_value("POLLFNR_WOECHENTLICH.txt")
.default_value("POLLFNR_TEST.txt")
.takes_value(true),
)
.arg(

View File

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 220 B

View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

View File

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 289 B

View File

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 126 B

View File

Before

Width:  |  Height:  |  Size: 158 B

After

Width:  |  Height:  |  Size: 158 B

View File

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 351 B

View File

Before

Width:  |  Height:  |  Size: 130 B

After

Width:  |  Height:  |  Size: 130 B

View File

Before

Width:  |  Height:  |  Size: 193 B

After

Width:  |  Height:  |  Size: 193 B

View File

Before

Width:  |  Height:  |  Size: 452 B

After

Width:  |  Height:  |  Size: 452 B

View File

Before

Width:  |  Height:  |  Size: 131 B

After

Width:  |  Height:  |  Size: 131 B

View File

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 223 B

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 768 B

After

Width:  |  Height:  |  Size: 768 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 455 KiB

After

Width:  |  Height:  |  Size: 455 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 237 KiB

After

Width:  |  Height:  |  Size: 237 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 237 KiB

After

Width:  |  Height:  |  Size: 237 KiB

View File

@@ -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 serde::{Deserialize, Serialize};
/// An enumeration of valid policy codes
/// right now, only "AS" is used
/// An enumeration of valid policy codes.
/// right now, only "AS" is used.
#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum PolicyCode {
/// Allianz Sachversicherung
AS
}
@@ -14,10 +20,56 @@ impl Default for PolicyCode {
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)]
pub enum Status {
/// Active -> the policy is active an supported
Active,
/// Inactive -> the policy is inactive or resigned
Inactive
}
@@ -26,54 +78,43 @@ impl Default for Status {
}
/// A communication type describes possible classifications of customer calls.
/// If not selected, the default will be 'unclassified'.
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct CommunicationType {
// Unfall, Bußgeldbescheid, Anhörung, Unfallflucht, Kaufvertrag,
// Vodafone, Kündigung, Lohn, Zeugnis, Nachbar, Vermieter, Rente, GdB, Verwaltungsrecht, Unterhalt, Geburt, Hochzeit
pub communication_id: String,
pub communication_name: String,
/// If the type isn't selected, the default will be 'unclassified -> XX'.
#[derive(Default, Deserialize, Serialize)]
pub struct CommunicationData {
/// pub communication_type: CommunicationType,
pub communication_type: String,
/// A literal name describing the selected communication type
pub communication_name: String
}
/// CSV Export
/// The structure elements are required for an export to a comma seperated text list.
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct CsvExportRecord {
// policy_code => Versicherungsscheinnummer: "AS1234567890"
// 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)
/// Versicherungsschein Code
pub policy_code: String,
/// Versicherungsscheinnummer (10-stellig, numerisch)
pub policy_number: u32,
/// Anrufer: "Vorname, Nachname"
pub policy_holder: String,
/// Sachverhalt: "Kurzschilderung"
pub facts: String,
/// Schadensart: "harm_name (harm_id)"
pub harm_type: String,
/// communication_type => Kommunikationszeichen: "(communication_name)"
pub communication_name: String,
/// ra_hotline => RA_Hotline: Kanzlei Laqua, Kanzlei Buschbell, Kanzlei DAH, Kanzlei Hiedemann
pub ra_hotline: String, // const "Kanzlei Hiedemann",
/// ivr_comment => Haftungs-/Deckungskommentar; #IVR (ggf. ergänzt um das Beratungsergebnis)
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.
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct HarmData {
/// Liste der Schadensdaten
pub harm_data: Vec<HarmType>,
/// Status der Schadenliste
//pub name: String,
pub selected: bool
}
@@ -82,6 +123,7 @@ pub struct HarmData {
/// The type code represents the unique harm identifier, bound with a literal name.
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct HarmType {
/// Kennzeichen des Schadenstyps
// Schadenersatz-RS im Verkehrsbereich (RS112)
// Ordnungswidrigkeits-RS im Verkehrsbereich (RS122)
// Straf-RS im Verkehrsbereich (RS121)
@@ -93,14 +135,18 @@ pub struct HarmType {
// Rechtsschutz im Familien- und Erbrecht (RS217)
// Wagnis nicht versicherbar / versichert (RS999)
pub harm_type: String,
/// Beschreibung des Schadenstyps
pub harm_name: String,
}
/// Structure used to verify a policy data element.
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct PolicyCheck {
/// Versicherungsschein-Prüfnummer
pub policy_check_number: String,
/// Referenz zur Versicherungsschein-Nummer
pub policy_number: String,
/// Validitätsergebnis
pub policy_number_valid: bool
}
@@ -121,74 +167,99 @@ pub struct PolicyCheck {
/// Structure collecting policy data elements
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
pub struct PolicyList {
/// Bescheibung der Versicherungsdatenliste
pub name: String,
/// Listenelemente der Versicherungsdatendaten
pub policy_list: Vec<PolicyDataList>,
}
/// implements helper methods, that manage lists of policy data collections
impl PolicyList {
/// Index auf Versicherungsliste zurückgeben (unveränderbar)
pub fn get(&self, index: usize) -> Option<&PolicyDataList> {
self.policy_list.get(index)
}
/// Index auf Versicherungsliste zurückgeben (veränderbar)
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyDataList> {
self.policy_list.get_mut(index)
}
/// Neuer Eintrag am Anfang der Liste einfügen.
pub fn insert_front(&mut self, policy_list: PolicyDataList) {
self.policy_list.insert(0, policy_list);
}
/// Prüfung ob Versicherungsliste keine Elemente enthält.
pub fn is_empty(&self) -> bool {
self.policy_list.is_empty()
}
/// Berechnet die Anzahl der Versicherungslisten Elemente.
pub fn len(&self) -> usize {
self.policy_list.len()
}
/// Neuen Versicherungslisten-Namen erzeugen
pub fn new(name: impl Into<String>) -> Self {
PolicyList {
name: name.into(),
..Default::default()
}
}
/// Element der Versicherungsliste anfügen
pub fn push(&mut self, policy_list: PolicyDataList) {
self.policy_list.push(policy_list);
}
/// Element der Versicherungsliste löschen
pub fn remove(&mut self, index: usize) -> PolicyDataList {
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.
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
pub struct PolicyDataList {
/// Verfalldatum des Versicherungslisten Elements
pub date_valid_until: Option<NaiveDateTime>,
/// Elemente des Versicherungsobjektes
pub policy_data: Vec<PolicyData>,
/// Name der Versicherungsliste
pub name: String,
/// Status der Versicherungsliste
pub selected: bool
}
/// implements the helper methods, to manage policy data collections.
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 {
// the new inserted element will be active by default
PolicyDataList {
@@ -199,35 +270,65 @@ impl PolicyDataList {
}
}
/// Versicherungselement anfügen
pub fn push(&mut self, policy_data: PolicyData) {
self.policy_data.push(policy_data);
}
pub fn insert_front(&mut self, policy_data: PolicyData) {
self.policy_data.insert(0, policy_data);
}
/// Versicherungselement löschen
pub fn remove(&mut self, index: usize) -> PolicyData {
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)
/// Structure representing a policy data element
/// This structure groups a set of fields that describes a policy number.
/// 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>
}
pub fn len(&self) -> usize {
self.policy_data.len()
/// 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
}
pub fn is_empty(&self) -> bool {
self.policy_data.is_empty()
}
}
into_property_source!(PolicyCheck);
into_property_source!(PolicyData);
into_property_source!(PolicyList);
// /// 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>
// }

View File

@@ -2,9 +2,11 @@ use orbtk::prelude::*;
use orbtk::theme::DEFAULT_THEME_CSS;
//use orbtk::theme::LIGHT_THEME_EXTENSION_CSS;
//use advotracker::services;
use advotracker::data;
// helper modules
pub mod base_state;
pub mod data;
pub mod keys;
// the frontend