diff --git a/Cargo.lock b/Cargo.lock index e980b78..eeabe45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,26 +37,6 @@ dependencies = [ "trust-dns-resolver", ] -[[package]] -name = "actix-files" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51e8a9146c12fce92a6e4c24b8c4d9b05268130bfd8d61bc587e822c32ce689" -dependencies = [ - "actix-service", - "actix-web", - "bitflags 1.3.2", - "bytes 0.5.6", - "derive_more", - "futures-core", - "futures-util", - "log", - "mime", - "mime_guess", - "percent-encoding", - "v_htmlescape", -] - [[package]] name = "actix-http" version = "2.2.2" @@ -306,7 +286,7 @@ checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom 0.2.12", "once_cell", - "version_check 0.9.4", + "version_check", ] [[package]] @@ -317,7 +297,7 @@ checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if 1.0.0", "once_cell", - "version_check 0.9.4", + "version_check", "zerocopy", ] @@ -673,15 +653,6 @@ dependencies = [ "serde", ] -[[package]] -name = "buf-min" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa17aa1cf56bdd6bb30518767d00e58019d326f3f05d8c3e0730b549d332ea83" -dependencies = [ - "bytes 0.5.6", -] - [[package]] name = "bumpalo" version = "3.14.0" @@ -886,7 +857,7 @@ checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" dependencies = [ "percent-encoding", "time", - "version_check 0.9.4", + "version_check", ] [[package]] @@ -1641,7 +1612,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", - "version_check 0.9.4", + "version_check", ] [[package]] @@ -2267,16 +2238,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "mime_guess" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -2357,16 +2318,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -dependencies = [ - "memchr", - "version_check 0.1.5", -] - [[package]] name = "num-traits" version = "0.2.17" @@ -3413,7 +3364,7 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" dependencies = [ - "version_check 0.9.4", + "version_check", ] [[package]] @@ -3474,7 +3425,7 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" dependencies = [ - "version_check 0.9.4", + "version_check", ] [[package]] @@ -3683,7 +3634,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "version_check 0.9.4", + "version_check", ] [[package]] @@ -3726,7 +3677,7 @@ dependencies = [ "standback", "stdweb", "time-macros", - "version_check 0.9.4", + "version_check", "winapi 0.3.9", ] @@ -3953,7 +3904,6 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" name = "ucelofka" version = "0.3.0" dependencies = [ - "actix-files", "actix-web", "anyhow", "assert_cmd", @@ -4083,15 +4033,6 @@ dependencies = [ "unic-common", ] -[[package]] -name = "unicase" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" -dependencies = [ - "version_check 0.9.4", -] - [[package]] name = "unicode-bidi" version = "0.3.15" @@ -4160,50 +4101,12 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" -[[package]] -name = "v_escape" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e0ab5fab1db278a9413d2ea794cb66f471f898c5b020c3c394f6447625d9d4" -dependencies = [ - "buf-min", - "v_escape_derive", -] - -[[package]] -name = "v_escape_derive" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29769400af8b264944b851c961a4a6930e76604f59b1fcd51246bab6a296c8c" -dependencies = [ - "nom", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "v_htmlescape" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f9a8af610ad6f7fc9989c9d2590d9764bc61f294884e9ee93baa58795174572" -dependencies = [ - "cfg-if 1.0.0", - "v_escape", -] - [[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - [[package]] name = "version_check" version = "0.9.4" diff --git a/ucelofka-data/src/invoice/v1.rs b/ucelofka-data/src/invoice/v1.rs index f3093e9..bc23d69 100644 --- a/ucelofka-data/src/invoice/v1.rs +++ b/ucelofka-data/src/invoice/v1.rs @@ -71,7 +71,7 @@ impl Invoice { .iter() .map(|i| i.id + 1) .max() - .unwrap_or_else(|| Utc::today().naive_utc().year() as u64 * 100_000 + 1) + .unwrap_or_else(|| Utc::now().date_naive().year() as u64 * 100_000 + 1) } pub fn new( @@ -86,7 +86,7 @@ impl Invoice { Self { _version: VERSION, id: new_id, - issue_day: Utc::today().format("%Y-%m-%d").to_string(), + issue_day: Utc::now().format("%Y-%m-%d").to_string(), due_day: (Utc::now() + Duration::days(DEFAULT_DUE)) .format("%Y-%m-%d") .to_string(), diff --git a/ucelofka-data/src/invoice/v2.rs b/ucelofka-data/src/invoice/v2.rs index 2dc9466..67ce236 100644 --- a/ucelofka-data/src/invoice/v2.rs +++ b/ucelofka-data/src/invoice/v2.rs @@ -94,7 +94,7 @@ impl Invoice { .iter() .map(|i| i.id + 1) .max() - .unwrap_or_else(|| Utc::today().naive_utc().year() as u64 * 100_000 + 1) + .unwrap_or_else(|| Utc::now().date_naive().year() as u64 * 100_000 + 1) } pub fn new( @@ -110,7 +110,7 @@ impl Invoice { Self { _version: VERSION, id: new_id, - issue_date: Utc::today().format("%Y-%m-%d").to_string(), + issue_date: Utc::now().format("%Y-%m-%d").to_string(), due_date: (Utc::now() + Duration::days( due.map(|v| i64::try_from(v).unwrap()) diff --git a/ucelofka/src/actions/account.rs b/ucelofka/src/actions/account.rs index 30098fe..c0ddc60 100644 --- a/ucelofka/src/actions/account.rs +++ b/ucelofka/src/actions/account.rs @@ -13,7 +13,7 @@ pub fn ids(data_path: &Path) -> Result { pub fn list(data_path: &Path) -> Result { let account_path = data_path.join(Path::new("accounts")); - Ok(Accounts::load(account_path.as_path())?) + Accounts::load(account_path.as_path()) } pub fn get(data_path: &Path, id: &str) -> Result { diff --git a/ucelofka/src/actions/customer.rs b/ucelofka/src/actions/customer.rs index 197af57..613614e 100644 --- a/ucelofka/src/actions/customer.rs +++ b/ucelofka/src/actions/customer.rs @@ -13,11 +13,11 @@ pub fn ids(data_path: &Path) -> Result { pub fn list(data_path: &Path) -> Result { let customer_path = data_path.join(Path::new("customers")); - Ok(Customers::load(customer_path.as_path())?) + Customers::load(customer_path.as_path()) } pub fn get(data_path: &Path, id: &str) -> Result { - Ok(list(data_path)? + list(data_path)? .get(id) - .ok_or_else(|| anyhow!("Customer {} not found.", id))?) + .ok_or_else(|| anyhow!("Customer {} not found.", id)) } diff --git a/ucelofka/src/actions/entry.rs b/ucelofka/src/actions/entry.rs index 38ddfcb..397c81f 100644 --- a/ucelofka/src/actions/entry.rs +++ b/ucelofka/src/actions/entry.rs @@ -14,13 +14,13 @@ pub fn ids(data_path: &Path) -> Result { pub fn list(data_path: &Path) -> Result { let entry_path = data_path.join(Path::new("entries")); - Ok(Entries::load(entry_path.as_path())?) + Entries::load(entry_path.as_path()) } pub fn get(data_path: &Path, id: &str) -> Result { - Ok(list(data_path)? + list(data_path)? .get(id) - .ok_or_else(|| anyhow!("Entry {} not found.", id))?) + .ok_or_else(|| anyhow!("Entry {} not found.", id)) } pub fn create( diff --git a/ucelofka/src/actions/identity.rs b/ucelofka/src/actions/identity.rs index f3650f5..bb85bc1 100644 --- a/ucelofka/src/actions/identity.rs +++ b/ucelofka/src/actions/identity.rs @@ -13,11 +13,11 @@ pub fn ids(data_path: &Path) -> Result { pub fn list(data_path: &Path) -> Result { let identity_path = data_path.join(Path::new("identities")); - Ok(Identities::load(identity_path.as_path())?) + Identities::load(identity_path.as_path()) } pub fn get(data_path: &Path, id: &str) -> Result { - Ok(list(data_path)? + list(data_path)? .get(id) - .ok_or_else(|| anyhow!("Identity {} not found.", id))?) + .ok_or_else(|| anyhow!("Identity {} not found.", id)) } diff --git a/ucelofka/src/actions/ids.rs b/ucelofka/src/actions/ids.rs index 8ae7337..6b31684 100644 --- a/ucelofka/src/actions/ids.rs +++ b/ucelofka/src/actions/ids.rs @@ -25,7 +25,7 @@ pub fn ids(data_path: &Path) -> Result { result += &template::list(data_path)? .templates .iter() - .map(|template| format!("{}\n", template.name)) + .map(|template| template.name.clone() + "\n") .collect::(); Ok(result) diff --git a/ucelofka/src/actions/invoice.rs b/ucelofka/src/actions/invoice.rs index b471236..2176215 100644 --- a/ucelofka/src/actions/invoice.rs +++ b/ucelofka/src/actions/invoice.rs @@ -19,13 +19,13 @@ struct WrappedInvoice(Invoice); impl TryFrom for Context { type Error = anyhow::Error; fn try_from(wrapped_invoice: WrappedInvoice) -> Result { - Ok(Self::from_serialize(wrapped_invoice.0).map_err(anyhow::Error::from)?) + Self::from_serialize(wrapped_invoice.0).map_err(anyhow::Error::from) } } -impl Into for Invoice { - fn into(self) -> WrappedInvoice { - WrappedInvoice(self) +impl From for WrappedInvoice { + fn from(val: Invoice) -> Self { + WrappedInvoice(val) } } @@ -75,8 +75,7 @@ pub fn create( .map_err(|err| anyhow!("{}", err))?; if git { - let git_path = - Path::new("invoices").join(Path::new(&format!("{}.yml", new_invoice.id.to_string()))); + let git_path = Path::new("invoices").join(Path::new(&format!("{}.yml", new_invoice.id))); let repo = Repository::open(data_path) .map_err(|err| anyhow!("Faield to open git repository {}", err))?; @@ -106,13 +105,13 @@ pub fn ids(data_path: &Path) -> Result { pub fn list(data_path: &Path) -> Result { let invoice_path = data_path.join(Path::new("invoices")); - Ok(Invoices::load(invoice_path.as_path())?) + Invoices::load(invoice_path.as_path()) } pub fn get(data_path: &Path, id: &str) -> Result { - Ok(list(data_path)? + list(data_path)? .get(id) - .ok_or_else(|| anyhow!("Invoice {} not found.", id))?) + .ok_or_else(|| anyhow!("Invoice {} not found.", id)) } pub fn render(data_path: &Path, invoice: &str, template: &str, git: bool) -> Result { diff --git a/ucelofka/src/actions/template.rs b/ucelofka/src/actions/template.rs index 31faa28..8b2590a 100644 --- a/ucelofka/src/actions/template.rs +++ b/ucelofka/src/actions/template.rs @@ -5,7 +5,7 @@ use crate::data::template::{Template, Templates}; pub fn list(data_path: &Path) -> Result { let templates_path = data_path.join(Path::new("templates")); - Ok(Templates::load(templates_path.as_path())?) + Templates::load(templates_path.as_path()) } pub fn get(data_path: &Path, id: &str) -> Result