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,
}),

View File

@@ -28,7 +28,6 @@ pub struct ShipmentRequest<'a> {
pub pickup_point_id: Option<&'a str>,
/// Cash-on-delivery amount in cents; `0` when payment is not COD.
pub cod_cents: i64,
pub currency: &'a str,
/// Total order value in cents (for insurance / customs declarations).
pub value_cents: i64,
pub weight_grams: i32,

View File

@@ -77,7 +77,7 @@ pub async fn create_shipment(ctx: &AppContext, req: ShipmentRequest<'_>) -> Resu
xml_escape(address_id),
value,
cod,
xml_escape(req.currency),
"EUR",
weight_kg,
xml_escape(sender_label),
);

View File

@@ -16,7 +16,6 @@ pub struct Model {
pub customer_name: Option<String>,
pub status: String,
pub total_cents: i64,
pub currency: String,
pub address: Option<String>,
pub city: Option<String>,
pub zip: Option<String>,

View File

@@ -17,7 +17,6 @@ pub struct Model {
pub description: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
pub short_description: Option<String>,
pub currency: String,
pub view_count: i32,
pub published: bool,
pub published_at: Option<DateTimeWithTimeZone>,

View File

@@ -53,7 +53,6 @@ pub async fn place(
let txn = ctx.db.begin().await?;
let mut subtotal: i64 = 0;
let mut currency = "EUR".to_string();
let mut snapshots = Vec::new();
for (variant_id, qty) in items {
let variant = product_variants::Entity::find_by_id(*variant_id)
@@ -75,7 +74,6 @@ pub async fn place(
)));
}
}
currency = product.currency.clone();
// Snapshot the price the buyer actually pays — public sale or, for a
// business account, their negotiated/lowest price (same resolver the
// cart and storefront use).
@@ -98,7 +96,6 @@ pub async fn place(
customer_name: Set(details.customer_name),
status: Set("pending".to_string()),
total_cents: Set(subtotal + details.method.price_cents),
currency: Set(currency),
user_id: Set(details.user_id),
account_type: Set(details.account_type),
company_name: Set(details.company_name),

View File

@@ -57,7 +57,7 @@ impl Entity {
let sql = format!(
r#"
SELECT p.created_at, p.updated_at, p.id, p.name, p.slug, p.description,
p.currency, p.view_count, p.published, p.published_at, p.category_id
p.short_description, p.view_count, p.published, p.published_at, p.category_id
FROM products p
WHERE {published_clause} (
p.search_vector @@ websearch_to_tsquery('sk_unaccent', $1)

View File

@@ -161,7 +161,6 @@ pub async fn seed_catalog(ctx: &AppContext) -> Result<()> {
name: Set(item.name.to_string()),
slug: Set(product_slug),
description: Set(Some(item.description.to_string())),
currency: Set("EUR".to_string()),
published: Set(true),
published_at: Set(Some(now.into())),
category_id: Set(category.map(|c| c.id)),

View File

@@ -40,7 +40,6 @@ pub fn detail(order: &orders::Model, bank_iban: &str, bank_account_name: &str) -
"subtotal": format_price(order.total_cents - order.shipping_cents),
"shipping": format_price(order.shipping_cents),
"total": format_price(order.total_cents),
"currency": order.currency,
"address": order.address,
"city": order.city,
"zip": order.zip,
@@ -68,7 +67,6 @@ pub fn summary(order: &orders::Model) -> Value {
"email": order.email,
"status": order.status,
"total": format_price(order.total_cents),
"currency": order.currency,
"created_at": order.created_at.to_rfc3339(),
})
}

View File

@@ -32,7 +32,6 @@ pub fn product_card(
"on_sale": priced.is_reduced(),
"is_business": priced.is_business,
"regular_price": format_price(priced.regular_cents),
"currency": product.currency,
"sku": representative.sku,
"stock": representative.stock,
"tracked": representative.tracked(),
@@ -71,7 +70,6 @@ pub fn product_form(product: &products::Model, images: &[product_images::Model])
"slug": product.slug,
"description": product.description,
"short_description": product.short_description,
"currency": product.currency,
"published": product.published,
"category_id": product.category_id,
"images": images