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:
2026-03-23 10:51:43 +01:00
parent bc586e21e7
commit 809f5d2a58
3 changed files with 18 additions and 11 deletions

View File

@@ -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()

View File

@@ -104,7 +104,7 @@
<div class="header">
<div>
<h1>Faktura - Kund {{ customer.customer_number }}</h1>
<div>Batchar: {{ batches | join(", ") }}</div>
<div>Period: {{ period }}</div>
</div>
<div class="meta">
<div>Genererad: {{ generated_date }}</div>
@@ -118,7 +118,7 @@
<span>{{ card.transactions.len() }} transaktioner</span>
</div>
<div class="card-summary">
Summa: {{ card.total_amount }} | Volym: {{ card.total_volume }} L
Summa: {{ card.total_amount }} Kr | Volym: {{ card.total_volume }} L
</div>
<table>
<thead>
@@ -154,7 +154,7 @@
{% endfor %}
<div class="grand-total">
Totalsumma:<span>{{ customer.grand_total }}</span>
Totalsumma:<span>{{ customer.grand_total }} Kr</span>
</div>
</body>
</html>

View File

@@ -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 @@
<body>
<h1>Fakturaöversikt</h1>
<div class="batch-info">
<strong>Bearbetade batchar:</strong> {{ batches | join(", ") }}
<div class="period">
<strong>Period:</strong> {{ period }}
</div>
<table>