diff options
author | Kaiden Fey <kookie@spacekookie.de> | 2021-02-21 14:56:11 +0100 |
---|---|---|
committer | Kaiden Fey <kookie@spacekookie.de> | 2021-02-21 14:56:11 +0100 |
commit | f186a7345dfc99347673f46e0daff0cb63ac8492 (patch) | |
tree | 5179ffd4654b80ea11a1656e28ef244439648ba4 /apps/koffice/libko/src/invoice.rs | |
parent | effbdeed66e8de8e769b8ac069926ad1a9110e62 (diff) |
k-office: initial code dumpk-office/init
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()); +} |