diff --git a/src/main.rs b/src/main.rs index 42c7833..57403fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -90,14 +90,14 @@ impl PreparedCustomer { #[template(path = "index.html")] struct IndexTemplate { customers: Vec<(String, usize)>, - batches: Vec, + period: String, } #[derive(Template)] #[template(path = "customer.html")] struct CustomerTemplate { customer: PreparedCustomer, - batches: Vec, + period: String, generated_date: String, } @@ -129,7 +129,14 @@ fn main() -> Result<(), Box> { batch.filename ); - let batch_filename = batch.filename.clone(); + let first_date = batch.transactions.first().map(|t| t.date).unwrap(); + let last_date = batch.transactions.last().map(|t| t.date).unwrap(); + let period = format!( + "{} - {}", + first_date.format("%Y-%m-%d"), + last_date.format("%Y-%m-%d") + ); + let customers = group_by_customer(&[batch]); let index_customers: Vec<(String, usize)> = customers @@ -139,7 +146,7 @@ fn main() -> Result<(), Box> { let html = IndexTemplate { customers: index_customers.clone(), - batches: vec![batch_filename.clone()], + period: period.clone(), } .render() .unwrap(); @@ -152,7 +159,7 @@ fn main() -> Result<(), Box> { let prepared = PreparedCustomer::from_customer(customer); let customer_html = CustomerTemplate { customer: prepared, - batches: vec![batch_filename.clone()], + period: period.clone(), generated_date: generated_date.clone(), } .render() diff --git a/templates/customer.html b/templates/customer.html index f500032..471aaaa 100644 --- a/templates/customer.html +++ b/templates/customer.html @@ -104,7 +104,7 @@

Faktura - Kund {{ customer.customer_number }}

-
Batchar: {{ batches | join(", ") }}
+
Period: {{ period }}
Genererad: {{ generated_date }}
@@ -118,7 +118,7 @@ {{ card.transactions.len() }} transaktioner
- Summa: {{ card.total_amount }} | Volym: {{ card.total_volume }} L + Summa: {{ card.total_amount }} Kr | Volym: {{ card.total_volume }} L
@@ -154,7 +154,7 @@ {% endfor %}
- Totalsumma:{{ customer.grand_total }} + Totalsumma:{{ customer.grand_total }} Kr
diff --git a/templates/index.html b/templates/index.html index 7052e4d..4798015 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,7 +27,7 @@ border-bottom: 2px solid #333; padding-bottom: 10px; } - .batch-info { + .period { margin-bottom: 15px; font-size: 11px; color: #666; @@ -61,8 +61,8 @@

Fakturaöversikt

-
- Bearbetade batchar: {{ batches | join(", ") }} +
+ Period: {{ period }}