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")]
|
#[template(path = "index.html")]
|
||||||
struct IndexTemplate {
|
struct IndexTemplate {
|
||||||
customers: Vec<(String, usize)>,
|
customers: Vec<(String, usize)>,
|
||||||
batches: Vec<String>,
|
period: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "customer.html")]
|
#[template(path = "customer.html")]
|
||||||
struct CustomerTemplate {
|
struct CustomerTemplate {
|
||||||
customer: PreparedCustomer,
|
customer: PreparedCustomer,
|
||||||
batches: Vec<String>,
|
period: String,
|
||||||
generated_date: String,
|
generated_date: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
batch.filename
|
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 customers = group_by_customer(&[batch]);
|
||||||
|
|
||||||
let index_customers: Vec<(String, usize)> = customers
|
let index_customers: Vec<(String, usize)> = customers
|
||||||
@@ -139,7 +146,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let html = IndexTemplate {
|
let html = IndexTemplate {
|
||||||
customers: index_customers.clone(),
|
customers: index_customers.clone(),
|
||||||
batches: vec![batch_filename.clone()],
|
period: period.clone(),
|
||||||
}
|
}
|
||||||
.render()
|
.render()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -152,7 +159,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let prepared = PreparedCustomer::from_customer(customer);
|
let prepared = PreparedCustomer::from_customer(customer);
|
||||||
let customer_html = CustomerTemplate {
|
let customer_html = CustomerTemplate {
|
||||||
customer: prepared,
|
customer: prepared,
|
||||||
batches: vec![batch_filename.clone()],
|
period: period.clone(),
|
||||||
generated_date: generated_date.clone(),
|
generated_date: generated_date.clone(),
|
||||||
}
|
}
|
||||||
.render()
|
.render()
|
||||||
|
|||||||
@@ -104,7 +104,7 @@
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
<div>
|
<div>
|
||||||
<h1>Faktura - Kund {{ customer.customer_number }}</h1>
|
<h1>Faktura - Kund {{ customer.customer_number }}</h1>
|
||||||
<div>Batchar: {{ batches | join(", ") }}</div>
|
<div>Period: {{ period }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<div>Genererad: {{ generated_date }}</div>
|
<div>Genererad: {{ generated_date }}</div>
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
<span>{{ card.transactions.len() }} transaktioner</span>
|
<span>{{ card.transactions.len() }} transaktioner</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-summary">
|
<div class="card-summary">
|
||||||
Summa: {{ card.total_amount }} | Volym: {{ card.total_volume }} L
|
Summa: {{ card.total_amount }} Kr | Volym: {{ card.total_volume }} L
|
||||||
</div>
|
</div>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<div class="grand-total">
|
<div class="grand-total">
|
||||||
Totalsumma:<span>{{ customer.grand_total }}</span>
|
Totalsumma:<span>{{ customer.grand_total }} Kr</span>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
border-bottom: 2px solid #333;
|
border-bottom: 2px solid #333;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
.batch-info {
|
.period {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
color: #666;
|
color: #666;
|
||||||
@@ -61,8 +61,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Fakturaöversikt</h1>
|
<h1>Fakturaöversikt</h1>
|
||||||
|
|
||||||
<div class="batch-info">
|
<div class="period">
|
||||||
<strong>Bearbetade batchar:</strong> {{ batches | join(", ") }}
|
<strong>Period:</strong> {{ period }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|||||||
Reference in New Issue
Block a user