whole eshop is now in euro

This commit is contained in:
Priec
2026-06-23 12:31:52 +02:00
parent 8085052b2b
commit 6b7422806f
33 changed files with 77 additions and 110 deletions

View File

@@ -198,7 +198,6 @@ async fn show(
"variant_id": variant.id,
"name": product.name,
"variant_label": variant.label,
"currency": product.currency,
"regular_price": format_price(d.regular_cents),
"business_price": format_price(b.price_cents),
"business_reduced": b.price_cents < d.regular_cents,
@@ -285,7 +284,6 @@ async fn price_edit(
"variant_id": variant.id,
"name": product.name,
"variant_label": variant.label,
"currency": product.currency,
"regular_price": format_price(d.regular_cents),
"regular_cents": d.regular_cents,
"business_price": format_price(business_cents),

View File

@@ -202,7 +202,6 @@ async fn ship(
country: order.country.as_deref(),
pickup_point_id: order.pickup_point_id.as_deref(),
cod_cents,
currency: &order.currency,
value_cents: goods_value,
weight_grams: DEFAULT_PARCEL_WEIGHT_GRAMS,
};

View File

@@ -53,7 +53,6 @@ struct ProductFields {
slug: String,
description: Option<String>,
short_description: Option<String>,
currency: String,
category_id: Option<i32>,
published: bool,
}
@@ -66,7 +65,6 @@ async fn parse_product_fields(
let name = form
.text("name")
.ok_or_else(|| Error::BadRequest("product name is required".to_string()))?;
let currency = form.text("currency").unwrap_or_else(|| "EUR".to_string());
let description = form.text("description");
let short_description = form.text("short_description");
let category_id = form.text("category_id").and_then(|s| s.parse::<i32>().ok());
@@ -94,7 +92,6 @@ async fn parse_product_fields(
slug,
description,
short_description,
currency,
category_id,
published,
})
@@ -366,7 +363,6 @@ fn product_row(
"id": product.id,
"name": product.name,
"slug": product.slug,
"currency": product.currency,
"stock": stock_display,
"variant_count": variant_count,
"has_options": variant_count > 1,
@@ -442,7 +438,6 @@ async fn create(
slug: Set(fields.slug),
description: Set(fields.description),
short_description: Set(fields.short_description),
currency: Set(fields.currency),
view_count: Set(0),
published: Set(fields.published),
published_at: Set(fields.published.then(|| chrono::Utc::now().into())),
@@ -557,7 +552,6 @@ async fn update(
product.slug = Set(fields.slug);
product.description = Set(fields.description);
product.short_description = Set(fields.short_description);
product.currency = Set(fields.currency);
product.category_id = Set(fields.category_id);
product.published = Set(fields.published);
if fields.published && !was_published {
@@ -704,7 +698,6 @@ async fn profiles_preview(
}
rows.push(json!({
"id": product.id,
"currency": product.currency,
"effective_price": format_price(priced.price_cents),
"effective_reduced": priced.is_reduced(),
"effective_percent_off": percent_off(priced.regular_cents, priced.price_cents),
@@ -816,13 +809,12 @@ impl DiscountRow {
}
}
fn to_json(&self, currency: &str) -> serde_json::Value {
fn to_json(&self) -> serde_json::Value {
json!({
"id": self.id,
"label": self.label,
"regular_cents": self.regular_cents,
"regular_price": format_price(self.regular_cents),
"currency": currency,
"mode": self.mode,
"fixed": self.fixed,
"percent": self.percent,
@@ -871,7 +863,7 @@ async fn discount_view(
audience: &str,
error: Option<&str>,
) -> Result<Response> {
let rows_json: Vec<_> = rows.iter().map(|r| r.to_json(&product.currency)).collect();
let rows_json: Vec<_> = rows.iter().map(DiscountRow::to_json).collect();
let has_discount = rows.iter().any(|r| r.has_discount);
format::view(
v,
@@ -880,7 +872,6 @@ async fn discount_view(
"product": {
"id": product.id,
"name": product.name,
"currency": product.currency,
},
"rows": rows_json,
"audience": audience,

View File

@@ -65,7 +65,7 @@ fn cart_cookie(value: String) -> Cookie<'static> {
}
/// Look up a variant whose product is published, returning the variant together
/// with its parent product (for name/slug/currency).
/// with its parent product (for name/slug).
async fn published_variant(
ctx: &AppContext,
variant_id: i32,
@@ -174,11 +174,6 @@ async fn cart_response(
}
let (lines, valid, total) = resolve_cart(ctx, &jar).await?;
let currency = lines
.first()
.and_then(|line| line["currency"].as_str())
.unwrap_or("EUR")
.to_string();
// Persist the re-validated cookie (drops now-invalid lines).
let jar = jar.add(cart_cookie(serialize_cart(&valid)));
let response = format::view(
@@ -187,7 +182,6 @@ async fn cart_response(
json!({
"items": lines,
"total": format_price(total),
"currency": currency,
"lang": current_lang(&jar),
}),
)?;
@@ -235,7 +229,6 @@ pub(crate) async fn resolve_cart(
"price": format_price(unit_price),
"regular_price": format_price(priced.regular_cents),
"on_sale": priced.is_reduced(),
"currency": product.currency,
"quantity": qty,
"stock": variant.stock,
"line_total": format_price(line_total),
@@ -252,11 +245,6 @@ async fn show(
State(ctx): State<AppContext>,
) -> Result<Response> {
let (lines, valid, total) = resolve_cart(&ctx, &jar).await?;
let currency = lines
.first()
.and_then(|line| line["currency"].as_str())
.unwrap_or("EUR")
.to_string();
// Drop any now-invalid lines from the cookie so the badge stays accurate.
let rebuilt = serialize_cart(&valid);
@@ -267,7 +255,6 @@ async fn show(
json!({
"items": lines,
"total": format_price(total),
"currency": currency,
"logged_in_admin": c.logged_in_admin,
"logged_in_customer": c.logged_in_customer,
"customer_name": c.customer_name,
@@ -288,11 +275,6 @@ async fn preview(
State(ctx): State<AppContext>,
) -> Result<Response> {
let (lines, valid, total) = resolve_cart(&ctx, &jar).await?;
let currency = lines
.first()
.and_then(|line| line["currency"].as_str())
.unwrap_or("EUR")
.to_string();
let rebuilt = serialize_cart(&valid);
let response = format::view(
&v,
@@ -300,7 +282,6 @@ async fn preview(
json!({
"items": lines,
"total": format_price(total),
"currency": currency,
"lang": current_lang(&jar),
}),
)?;

View File

@@ -81,11 +81,6 @@ async fn checkout_page(
if lines.is_empty() {
return format::redirect("/cart");
}
let currency = lines
.first()
.and_then(|line| line["currency"].as_str())
.unwrap_or("EUR")
.to_string();
let methods: Vec<serde_json::Value> = enabled_shipping_methods(&ctx)
.await?
@@ -127,7 +122,6 @@ async fn checkout_page(
"items": lines,
"subtotal": format_price(subtotal),
"subtotal_cents": subtotal,
"currency": currency,
"shipping_methods": methods,
"packeta_api_key": settings::get(&ctx, "packeta_api_key").unwrap_or(""),
"logged_in_admin": is_admin,

View File

@@ -411,7 +411,6 @@ async fn show(
"name": product.name,
"slug": product.slug,
"description": product.description,
"currency": product.currency,
"variant_count": 0,
"has_options": false,
}),