Skip to content

Commit

Permalink
Add prototype for regular bookings
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicparga committed Sep 2, 2023
1 parent d955f81 commit 735c2f6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
17 changes: 15 additions & 2 deletions .vscode/debugging.billo.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
{
"booking-list": [
"analysis": [],
"regular bookings": [
{
"date": "2023.09.01",
"sender": "",
"receiver": "",
"amount": "300,20 EUR",
"turnus": "each 3 months",
"labels": [
"Bargeld"
]
}
],
"ongoing bookings": [
{
"date": "2023.09.01",
"sender": "",
"receiver": "",
"amount": "300,20 EUR",
"topic": "",
"reference": "",
"label_list": [
"labels": [
"Bargeld"
]
}
Expand Down
43 changes: 41 additions & 2 deletions billo/lib/running/datastructures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Reference = String;

#[derive(Deserialize, Debug)]
pub enum Label {
#[serde(alias = "Bargeld")]
#[serde(rename = "Bargeld")]
CASH,
}

Expand All @@ -33,6 +33,24 @@ impl FromStr for Currency {
}
}

#[derive(Deserialize, Debug)]
enum Turnus {
#[serde(alias = "yearly")]
#[serde(alias = "each 12 months")]
PER_YEAR_1_TIME,
#[serde(alias = "half a year")]
#[serde(alias = "each 6 months")]
PER_YEAR_2_TIMES,
#[serde(alias = "each 4 months")]
PER_YEAR_3_TIMES,
#[serde(alias = "each quarter")]
#[serde(alias = "each 3 months")]
PER_YEAR_4_TIMES,
#[serde(alias = "monthly")]
#[serde(alias = "each 1 months")]
PER_MONTH_1_TIME,
}

#[derive(Deserialize, Debug)]
struct Amount {
cents: i32,
Expand Down Expand Up @@ -105,6 +123,9 @@ fn de_date<'de, D: Deserializer<'de>>(deserializer: D) -> Result<NaiveDate, D::E
}
}

#[derive(Deserialize, Debug)]
pub struct Analysis {}

#[derive(Deserialize, Debug)]
pub struct Booking {
#[serde(deserialize_with = "de_date")]
Expand All @@ -115,11 +136,29 @@ pub struct Booking {
amount: Amount,
topic: Topic,
reference: Reference,
#[serde(rename = "labels")]
label_list: Vec<Label>,
}

#[derive(Deserialize, Debug)]
pub struct Regularity {
#[serde(deserialize_with = "de_date")]
date: NaiveDate,
sender: Sender,
receiver: Receiver,
#[serde(deserialize_with = "de_amount")]
amount: Amount,
turnus: Turnus,
#[serde(rename = "labels")]
label_list: Vec<Label>,
}

#[derive(Deserialize, Debug)]
pub struct Config {
#[serde(rename = "booking-list")]
#[serde(rename = "analysis")]
pub analysis_list: Vec<Analysis>,
#[serde(rename = "regular bookings")]
pub regularity_list: Vec<Regularity>,
#[serde(rename = "ongoing bookings")]
pub booking_list: Vec<Booking>,
}
2 changes: 1 addition & 1 deletion billo/lib/running/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ pub fn run(config_filepathbuf: PathBuf) {
}
};

println!("{:?}", config.booking_list)
println!("{:?}", config)
}

0 comments on commit 735c2f6

Please sign in to comment.