123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- use std::collections::HashMap;
- use super::{AccountName, UnitName};
- #[derive(Debug, serde::Deserialize, PartialEq)]
- #[serde(deny_unknown_fields, rename_all = "snake_case")]
- pub enum CsvColumnSpec {
- Ignore,
- Datestamp,
- Title,
- Deposit,
- Withdraw,
- Change,
- Balance,
- Unit,
- }
- #[derive(Debug, serde::Deserialize)]
- #[serde(deny_unknown_fields)]
- pub struct CsvImportSpec {
- pub skip_start: Option<usize>,
- pub skip_end: Option<usize>,
- pub cols: Vec<CsvColumnSpec>,
- pub date_format: String,
- }
- #[derive(Debug, serde::Deserialize)]
- #[serde(deny_unknown_fields, tag = "format", rename_all = "snake_case")]
- pub enum ImportFileFormat {
- Csv(CsvImportSpec),
- }
- #[derive(Debug, serde::Deserialize)]
- #[serde(deny_unknown_fields)]
- pub struct AccountSpec {
- pub title: Option<String>,
- pub description: Option<String>,
- pub annotations: Option<HashMap<String, String>>,
- pub unit: Option<UnitName>,
- pub import: Option<ImportFileFormat>,
- }
- #[derive(Debug, serde::Deserialize)]
- #[serde(deny_unknown_fields)]
- pub struct UnitSpec {
- pub name: UnitName,
- pub precision: Option<u32>,
- }
- #[derive(Debug, serde::Deserialize)]
- #[serde(deny_unknown_fields)]
- pub struct SpecRoot {
- pub ledger_path: std::path::PathBuf,
- pub units: HashMap<UnitName, UnitSpec>,
- pub placeholder_account: AccountName,
- pub accounts: HashMap<AccountName, AccountSpec>,
- }
|