From f3af573bd7d18246a12ca8dcfb5f363e7d9a1eb5 Mon Sep 17 00:00:00 2001 From: Ralf Zerres Date: Mon, 22 Jun 2020 14:15:22 +0200 Subject: [PATCH] frontend: data: define export structure for csv files * data need to be transfered as a csv-file attachment via email * each row takes a semicolon separeted list of string fields * this structure is defined as rust 'struct CSVExport' * the struct CSVExport will reference to its child stuctures. Signed-off-by: Ralf Zerres --- frontend/src/data.rs | 90 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 12 deletions(-) diff --git a/frontend/src/data.rs b/frontend/src/data.rs index 6c9fb95..6d4b234 100644 --- a/frontend/src/data.rs +++ b/frontend/src/data.rs @@ -3,10 +3,63 @@ use orbtk::prelude::*; use chrono::NaiveDateTime; use serde::{Deserialize, Serialize}; +#[derive(Default, Debug, Clone, Deserialize, Serialize)] +pub struct HarmElement { + // Schadenersatz-RS im Verkehrsbereich (RS112) + // Ordnungswidrigkeits-RS im Verkehrsbereich (RS122) + // Straf-RS im Verkehrsbereich (RS121) + // Vertrags-RS im Verkehrsbereich (RS118) + // Vertrags-RS im Privatbereich (RS218) + // Arbeits-RS im Berufsbereich (RS315) + // WuG-RS im Privatbereich (RS220) + // Sozialgerichts-RS im Privatbereich (RS216) + // Rechtsschutz im Familien- und Erbrecht (RS217) + // Wagnis nicht versicherbar / versichert (RS999) + pub harm_id: String, + pub harm_name: String, +} + +#[derive(Default, Debug, Clone, Deserialize, Serialize)] +pub struct HarmType { + pub harm_type: Vec, + pub name: String, + pub selected: bool +} + +#[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, +} + + +/// CSV Export +#[derive(Default, Debug, Clone, Deserialize, Serialize)] +pub struct CSVExport { + // 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) + pub policy_id: String, + pub policy_number: u32, + pub policy_holder: String, + pub facts: String, + pub harm_type: String, + pub communication_name: String, + pub ra_hotline: String, // const "Kanzlei Hiedemann", + pub ivr_comment: String, +} + /// Structure used to verify a policy data element. #[derive(Default, Debug, Clone, Deserialize, Serialize)] pub struct PolicyCheck { - pub policy_code: String, + pub policy_id: String, + pub policy_number: String, pub isvalid: bool } @@ -45,16 +98,29 @@ impl PolicyList { } } +// Valid policy codes are represented in this Enumeration +// right now, only "AS" is used +//enum PolicyCode { +// CodeName(String), +//} + /// Structure representing a policy data element. #[derive(Default, Debug, Clone, Deserialize, Serialize)] pub struct PolicyElement { + // DION VERS POLLFNR + // 1 AS 1515735810 + // DION: Allianz id => len = 1?? + // VERS: policy_code => enum(AS; ??) + // POLLFNR: policy_number => len = 10 + pub dion: u8, // is String16 a better default-type? pub policy_code: String, + pub policy_number: u32, pub date_inserted: Option, - pub isvalid: bool + pub isactive: bool } -/// Structure grouping valid policy data elemnts +/// Structure grouping valid policy data elements #[derive(Default, Debug, Clone, Deserialize, Serialize)] pub struct PolicyData { pub date_valid_until: Option, @@ -63,44 +129,44 @@ pub struct PolicyData { pub selected: bool } -/// implements helper methods, that manage the policy data collections. +/// implements the helper methods, to manage policy data collections. impl PolicyData { pub fn new(name: impl Into) -> Self { // the new inserted element will be active by default PolicyData { - name: name.into(), date_valid_until: None, + name: name.into(), selected: true, ..Default::default() } } pub fn push(&mut self, policy_element: PolicyElement) { - self.list.push(policy_element); + self.policy_elements.push(policy_element); } pub fn insert_front(&mut self, policy_element: PolicyElement) { - self.list.insert(0, policy_element); + self.policy_elements.insert(0, policy_element); } pub fn remove(&mut self, index: usize) -> PolicyElement { - self.list.remove(index) + self.policy_elements.remove(index) } pub fn get(&self, index: usize) -> Option<&PolicyElement> { - self.list.get(index) + self.policy_elements.get(index) } pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyElement> { - self.list.get_mut(index) + self.policy_elements.get_mut(index) } pub fn len(&self) -> usize { - self.list.len() + self.policy_elements.len() } pub fn is_empty(&self) -> bool { - self.list.is_empty() + self.policy_elements.is_empty() } }