234 lines
7.0 KiB
Rust
234 lines
7.0 KiB
Rust
use orbtk::prelude::*;
|
|
|
|
use chrono::NaiveDateTime;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// An enumeration of valid policy codes
|
|
/// right now, only "AS" is used
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub enum PolicyCode {
|
|
AS
|
|
}
|
|
|
|
impl Default for PolicyCode {
|
|
fn default() -> Self { PolicyCode::AS }
|
|
}
|
|
|
|
/// Status of a given policy data element (eg: active / inactive)
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub enum Status {
|
|
Active,
|
|
Inactive
|
|
}
|
|
|
|
impl Default for Status {
|
|
fn default() -> Self { Status::Active }
|
|
}
|
|
|
|
/// 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,
|
|
}
|
|
|
|
/// 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)
|
|
pub policy_code: 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,
|
|
}
|
|
|
|
/// 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 {
|
|
pub harm_data: Vec<HarmType>,
|
|
//pub name: String,
|
|
pub selected: bool
|
|
}
|
|
|
|
/// Harm types are destincted by a type code.
|
|
/// The type code represents the unique harm identifier, bound with a literal name.
|
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
|
pub struct HarmType {
|
|
// 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_type: String,
|
|
pub harm_name: String,
|
|
}
|
|
|
|
/// Structure used to verify a policy data element.
|
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
|
pub struct PolicyCheck {
|
|
pub policy_check_number: String,
|
|
pub policy_number: String,
|
|
pub policy_number_valid: bool
|
|
}
|
|
|
|
// #[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
// pub struct PolicyCheckList {
|
|
// pub title: String,
|
|
// pub list: Vec<PolicyCheck>
|
|
// }
|
|
|
|
// impl PolicyCheckList {
|
|
// pub fn new(title: impl Into<String>) -> Self {
|
|
// PolicyCheckList {
|
|
// title: title.into(),
|
|
// ..Default::default()
|
|
// }
|
|
// }
|
|
|
|
/// Structure collecting policy data elements
|
|
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
|
pub struct PolicyList {
|
|
pub name: String,
|
|
pub policy_list: Vec<PolicyDataList>,
|
|
}
|
|
|
|
/// implements helper methods, that manage lists of policy data collections
|
|
impl PolicyList {
|
|
pub fn get(&self, index: usize) -> Option<&PolicyDataList> {
|
|
self.policy_list.get(index)
|
|
}
|
|
|
|
pub fn get_mut(&mut self, index: usize) -> Option<&mut PolicyDataList> {
|
|
self.policy_list.get_mut(index)
|
|
}
|
|
|
|
pub fn insert_front(&mut self, policy_list: PolicyDataList) {
|
|
self.policy_list.insert(0, policy_list);
|
|
}
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
self.policy_list.is_empty()
|
|
}
|
|
|
|
pub fn len(&self) -> usize {
|
|
self.policy_list.len()
|
|
}
|
|
|
|
pub fn new(name: impl Into<String>) -> Self {
|
|
PolicyList {
|
|
name: name.into(),
|
|
..Default::default()
|
|
}
|
|
}
|
|
pub fn push(&mut self, policy_list: PolicyDataList) {
|
|
self.policy_list.push(policy_list);
|
|
}
|
|
|
|
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 {
|
|
pub date_valid_until: Option<NaiveDateTime>,
|
|
pub policy_data: Vec<PolicyData>,
|
|
pub name: String,
|
|
pub selected: bool
|
|
}
|
|
|
|
/// implements the helper methods, to manage policy data collections.
|
|
impl PolicyDataList {
|
|
pub fn new(name: impl Into<String>) -> Self {
|
|
// the new inserted element will be active by default
|
|
PolicyDataList {
|
|
date_valid_until: None,
|
|
name: name.into(),
|
|
selected: true,
|
|
..Default::default()
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
pub fn len(&self) -> usize {
|
|
self.policy_data.len()
|
|
}
|
|
|
|
pub fn is_empty(&self) -> bool {
|
|
self.policy_data.is_empty()
|
|
}
|
|
}
|
|
|
|
into_property_source!(PolicyCheck);
|
|
into_property_source!(PolicyData);
|
|
into_property_source!(PolicyList);
|