Add Kr currency unit and period display
- Show Kr after all amounts and prices - Replace batch reference with period (first-last date) - Same period shown on all customer invoices
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -90,14 +90,14 @@ impl PreparedCustomer {
|
||||
#[template(path = "index.html")]
|
||||
struct IndexTemplate {
|
||||
customers: Vec<(String, usize)>,
|
||||
batches: Vec<String>,
|
||||
period: String,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "customer.html")]
|
||||
struct CustomerTemplate {
|
||||
customer: PreparedCustomer,
|
||||
batches: Vec<String>,
|
||||
period: String,
|
||||
generated_date: String,
|
||||
}
|
||||
|
||||
@@ -129,7 +129,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
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<dyn std::error::Error>> {
|
||||
|
||||
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<dyn std::error::Error>> {
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user