diff --git a/ucelofka-data/src/invoice/v1.rs b/ucelofka-data/src/invoice/v1.rs index bc23d69..f8e7e4a 100644 --- a/ucelofka-data/src/invoice/v1.rs +++ b/ucelofka-data/src/invoice/v1.rs @@ -87,7 +87,7 @@ impl Invoice { _version: VERSION, id: new_id, issue_day: Utc::now().format("%Y-%m-%d").to_string(), - due_day: (Utc::now() + Duration::days(DEFAULT_DUE)) + due_day: (Utc::now() + Duration::try_days(DEFAULT_DUE).unwrap_or_default()) .format("%Y-%m-%d") .to_string(), issuer: Issuer { diff --git a/ucelofka-data/src/invoice/v2.rs b/ucelofka-data/src/invoice/v2.rs index 67ce236..04060c5 100644 --- a/ucelofka-data/src/invoice/v2.rs +++ b/ucelofka-data/src/invoice/v2.rs @@ -112,10 +112,11 @@ impl Invoice { id: new_id, issue_date: Utc::now().format("%Y-%m-%d").to_string(), due_date: (Utc::now() - + Duration::days( + + Duration::try_days( due.map(|v| i64::try_from(v).unwrap()) .unwrap_or(DEFAULT_DUE), - )) + ) + .unwrap_or_default()) .format("%Y-%m-%d") .to_string(), issuer: Issuer {