diff options
Diffstat (limited to 'apps/koffice/libko/src/invoice.rs')
-rw-r--r-- | apps/koffice/libko/src/invoice.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/apps/koffice/libko/src/invoice.rs b/apps/koffice/libko/src/invoice.rs new file mode 100644 index 000000000000..737513785916 --- /dev/null +++ b/apps/koffice/libko/src/invoice.rs @@ -0,0 +1,35 @@ +use chrono::NaiveDate; +use serde::{Deserialize, Serialize}; +use std::string::ToString; + +/// A specification to build invoice IDs with +#[derive(Serialize, Deserialize)] +pub enum InvoiceId { + YearMonthId(u16, u8, usize), +} + +impl ToString for InvoiceId { + fn to_string(&self) -> String { + match self { + Self::YearMonthId(yr, mo, id) => format!("#{}-{:02}-{:04}", yr, mo, id), + } + } +} + +/// An invoice for a specific project +#[derive(Serialize, Deserialize)] +pub struct Invoice { + id: InvoiceId, + client: String, + project: String, + date: NaiveDate, + amount: usize, + currency: String, + vat: u8, +} + +#[test] +fn invoice_id_fmt() { + let inv_id = InvoiceId::YearMonthId(2020, 06, 0055); + assert_eq!(inv_id.to_string(), "#2020-06-0055".to_string()); +} |