cal_core/accounting/
mod.rs

1use crate::RecordReference;
2use bson::{DateTime, Uuid};
3use serde::{Deserialize, Serialize};
4
5pub mod rating;
6pub mod product;
7pub mod code_deck;
8
9#[derive(Serialize, Deserialize, Clone)]
10pub struct ServiceCharge {
11    #[serde(deserialize_with = "crate::shared::object_id_as_string", rename = "_id")]
12    pub id: String,
13    #[serde(rename = "customer")]
14    pub account: RecordReference,
15    pub reference: String,
16    pub name: String,
17    pub category: String,
18    pub description: String,
19    pub unit: f32,
20    pub price: f32,
21    pub qty: u16,
22    pub total: u16,
23    pub start: DateTime,
24    pub target: ServiceChargeTarget,
25}
26
27#[derive(Serialize, Deserialize, Clone)]
28pub enum ServiceChargeTarget {
29    Reseller,
30    Direct,
31}
32
33#[derive(Serialize, Deserialize, Clone)]
34#[serde(tag = "_id")]
35pub enum VatType {
36    #[serde(rename = "uk_drc")]
37    UkDrc,
38    #[serde(rename = "uk_vat")]
39    UkVat,
40}
41
42#[derive(Serialize, Deserialize, Clone)]
43pub struct VatTypeStruct {
44    pub title: String,
45    pub enable: bool,
46    pub reverse: bool,
47    pub value: f32,
48}
49
50#[derive(Serialize, Deserialize, Clone)]
51#[serde(rename_all = "camelCase")]
52pub struct Finance {
53    pub address: Address,
54    pub name: String,
55    pub currency: String,
56    pub email_recipients: Vec<String>,
57    pub vat_number: Option<String>,
58    pub profile: String,
59    pub vat_amount: u16,
60    pub payment_terms: u16,
61    pub enable: bool,
62    pub email: bool,
63    pub drc: bool,
64    pub vat_type: VatType,
65}
66
67#[derive(Serialize, Deserialize, Clone)]
68#[serde(rename_all = "camelCase")]
69pub struct InvoiceGroup {
70    #[serde(deserialize_with = "crate::shared::object_id_as_string", rename = "_id")]
71    pub id: String,
72    pub group: String,
73    pub line1: String,
74    pub line2: String,
75    pub level1: String,
76    pub level2: String,
77    pub postal_code: String,
78    pub country: String,
79    pub name: String,
80    pub account_code: u16,
81    pub currency: String,
82    pub vat_number: String,
83    pub vat_amount: u8,
84    pub payment_terms: u8,
85    pub enable: bool,
86    pub email: bool,
87    pub drc: bool,
88}
89
90
91
92#[derive(Serialize, Deserialize, Clone)]
93#[serde(rename_all = "camelCase")]
94pub struct Address {
95    #[serde(default = "crate::shared::build_id")]
96    pub id: String,
97    #[serde(default)]
98    pub line1: String,
99    #[serde(default)]
100    pub line2: String,
101    #[serde(default)]
102    pub level1: String,
103    #[serde(default)]
104    pub level2: String,
105    #[serde(default)]
106    pub postal_code: String,
107    #[serde(default)]
108    pub country: String,
109}
110
111impl Default for Address {
112    fn default() -> Self {
113        Self {
114            id: Uuid::new().to_string(),
115            line1: String::from(""),
116            line2: String::from(""),
117            level1: String::from(""),
118            level2: String::from(""),
119            postal_code: String::from(""),
120            country: String::from(""),
121        }
122    }
123}