From 6b7422806fe4022684075f386ab6e966f132c842 Mon Sep 17 00:00:00 2001 From: Priec Date: Tue, 23 Jun 2026 12:31:52 +0200 Subject: [PATCH] whole eshop is now in euro --- assets/views/account/order_detail.html | 10 ++++----- assets/views/account/orders.html | 2 +- assets/views/admin/catalog/discount_form.html | 7 +++---- assets/views/admin/catalog/product_form.html | 11 +++------- assets/views/admin/catalog/products.html | 2 +- assets/views/admin/customers/price_form.html | 8 +++---- assets/views/admin/customers/show.html | 6 +++--- assets/views/admin/orders/index.html | 2 +- assets/views/admin/orders/show.html | 6 +++--- assets/views/macros/ui.html | 4 ++-- assets/views/shop/_card.html | 6 +++--- assets/views/shop/_cart_body.html | 8 +++---- assets/views/shop/_cart_preview.html | 8 +++---- assets/views/shop/checkout.html | 10 ++++----- assets/views/shop/order_confirmed.html | 10 ++++----- assets/views/shop/show.html | 6 +++--- migration/src/lib.rs | 2 ++ .../src/m20260623_000003_drop_currency.rs | 20 ++++++++++++++++++ src/controllers/admin_customers.rs | 2 -- src/controllers/admin_orders.rs | 1 - src/controllers/admin_products.rs | 13 ++---------- src/controllers/cart.rs | 21 +------------------ src/controllers/checkout.rs | 6 ------ src/controllers/shop.rs | 1 - src/integrations/mod.rs | 1 - src/integrations/packeta.rs | 2 +- src/models/_entities/orders.rs | 1 - src/models/_entities/products.rs | 1 - src/models/orders.rs | 3 --- src/models/products.rs | 2 +- src/seed.rs | 1 - src/views/checkout.rs | 2 -- src/views/shop.rs | 2 -- 33 files changed, 77 insertions(+), 110 deletions(-) create mode 100644 migration/src/m20260623_000003_drop_currency.rs diff --git a/assets/views/account/order_detail.html b/assets/views/account/order_detail.html index 7926ca5..a31dd13 100644 --- a/assets/views/account/order_detail.html +++ b/assets/views/account/order_detail.html @@ -30,18 +30,18 @@ {% for item in items %}
  • {{ item.product_name }}{% if item.variant_label %} · {{ item.variant_label }}{% endif %} × {{ item.quantity }} - {{ item.line_total }} {{ order.currency }} + {{ item.line_total }} €
  • {% endfor %}
    -
    {{ t(key="checkout-subtotal", lang=lang | default(value='sk')) }}{{ order.subtotal }} {{ order.currency }}
    -
    {{ order.carrier_name }}{{ order.shipping }} {{ order.currency }}
    +
    {{ t(key="checkout-subtotal", lang=lang | default(value='sk')) }}{{ order.subtotal }} €
    +
    {{ order.carrier_name }}{{ order.shipping }} €
    {% if order.pickup_point_name %}
    {{ order.pickup_point_name }}
    {% endif %}
    {{ t(key="order-total", lang=lang | default(value='sk')) }} - {{ order.total }} {{ order.currency }} + {{ order.total }} €
    @@ -68,7 +68,7 @@ {{ t(key="bank-account-name", lang=lang | default(value='sk')) }}{{ order.bank_account_name }} IBAN{{ order.bank_iban }} {{ t(key="bank-variable-symbol", lang=lang | default(value='sk')) }}{{ order.variable_symbol }} - {{ t(key="bank-amount", lang=lang | default(value='sk')) }}{{ order.total }} {{ order.currency }} + {{ t(key="bank-amount", lang=lang | default(value='sk')) }}{{ order.total }} € {% endif %} diff --git a/assets/views/account/orders.html b/assets/views/account/orders.html index 5f9c437..77ea532 100644 --- a/assets/views/account/orders.html +++ b/assets/views/account/orders.html @@ -22,7 +22,7 @@
    {{ self::status_badge(status=order.status) }} - {{ order.total }} {{ order.currency }} + {{ order.total }} €
    {% endmacro order_row %} diff --git a/assets/views/admin/catalog/discount_form.html b/assets/views/admin/catalog/discount_form.html index 6321118..d730bef 100644 --- a/assets/views/admin/catalog/discount_form.html +++ b/assets/views/admin/catalog/discount_form.html @@ -38,7 +38,7 @@ x-text="row.label || ('#' + row.id)"> {{ t(key="price", lang=lang | default(value='sk')) }}: - + @@ -80,9 +80,9 @@ class="flex flex-wrap items-center justify-between gap-3 rounded-radius border border-outline bg-surface-alt px-4 py-2.5 text-sm dark:border-outline-dark dark:bg-surface-dark/40"> {{ t(key="discount-preview-after", lang=lang | default(value='sk')) }} - + + x-text="money(afterCents(row)) + ' €'"> @@ -106,7 +106,6 @@ label: r.label || '', regular_cents: r.regular_cents, regular_price: r.regular_price, - currency: r.currency, mode: r.mode || 'fixed', fixed: r.fixed || '', percent: r.percent || '', diff --git a/assets/views/admin/catalog/product_form.html b/assets/views/admin/catalog/product_form.html index c079944..bc3b148 100644 --- a/assets/views/admin/catalog/product_form.html +++ b/assets/views/admin/catalog/product_form.html @@ -21,9 +21,9 @@ {{ ui::csrf_field() }} {% if product %} - {% set v_name = product.name %}{% set v_currency = product.currency %}{% set v_desc = product.description | default(value="") %}{% set v_short = product.short_description | default(value="") %}{% set v_pub = product.published %} + {% set v_name = product.name %}{% set v_desc = product.description | default(value="") %}{% set v_short = product.short_description | default(value="") %}{% set v_pub = product.published %} {% else %} - {% set v_name = "" %}{% set v_currency = "EUR" %}{% set v_desc = "" %}{% set v_short = "" %}{% set v_pub = false %} + {% set v_name = "" %}{% set v_desc = "" %}{% set v_short = "" %}{% set v_pub = false %} {% endif %} {% set inp = "w-full rounded-radius border border-outline bg-surface-alt px-3 py-2 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:border-outline-dark dark:bg-surface-dark-alt/50 dark:text-on-surface-dark dark:focus-visible:outline-primary-dark" %} {% set sublabel = "text-xs font-medium text-on-surface/70 dark:text-on-surface-dark/70" %} @@ -33,11 +33,6 @@ {{ ui::input(name="name", id="name", required=true, value=v_name) }} -
    - - {{ ui::input(name="currency", id="currency", value=v_currency, attrs='maxlength="3"', extra="uppercase") }} -
    - {# --- Variants / options editor ------------------------------------------- #} {# Each product is sold as one or more variants (a free-text label such as #} {# "10cm x 13cm" or "5ml" plus its own price). Price is required. Stock is #} @@ -76,7 +71,7 @@
    - +
    diff --git a/assets/views/admin/catalog/products.html b/assets/views/admin/catalog/products.html index a64ac65..16093d8 100644 --- a/assets/views/admin/catalog/products.html +++ b/assets/views/admin/catalog/products.html @@ -122,7 +122,7 @@ - {% if product.has_options %}{{ t(key="from-price", price=product.regular_price, lang=lang | default(value='sk')) }}{% else %}{{ product.regular_price }}{% endif %} {{ product.currency }} + {% if product.has_options %}{{ t(key="from-price", price=product.regular_price, lang=lang | default(value='sk')) }}{% else %}{{ product.regular_price }}{% endif %} € {{ product.variant_count }} {{ ui::eff_price(p=product) }} diff --git a/assets/views/admin/customers/price_form.html b/assets/views/admin/customers/price_form.html index 1bb6c73..4558b75 100644 --- a/assets/views/admin/customers/price_form.html +++ b/assets/views/admin/customers/price_form.html @@ -38,15 +38,15 @@
    {{ t(key="price", lang=lang | default(value='sk')) }} - {{ product.regular_price }} {{ product.currency }} + {{ product.regular_price }} €
    {{ t(key="business-price", lang=lang | default(value='sk')) }} - {{ product.business_price }} {{ product.currency }} + {{ product.business_price }} €
    {{ t(key="effective-price", lang=lang | default(value='sk')) }} - {{ product.effective_price }} {{ product.currency }} + {{ product.effective_price }} €
    @@ -62,7 +62,7 @@
    {{ t(key="negotiated-price", lang=lang | default(value='sk')) }} - {{ product.currency }} +

    {{ t(key="discount-must-be-positive", lang=lang | default(value='sk')) }}

    diff --git a/assets/views/admin/customers/show.html b/assets/views/admin/customers/show.html index 172790b..aba3a30 100644 --- a/assets/views/admin/customers/show.html +++ b/assets/views/admin/customers/show.html @@ -82,14 +82,14 @@ {% if product.business_reduced %} - {{ product.business_price }} {{ product.currency }} + {{ product.business_price }} € {{ product.regular_price }} {% else %} - {{ product.business_price }} {{ product.currency }} + {{ product.business_price }} € {% endif %} - {{ product.effective_price }} {{ product.currency }} + {{ product.effective_price }} € {% if product.collision %}{{ ui::badge(label=t(key="collision", lang=lang | default(value='sk')), variant="warning") }}{% endif %} diff --git a/assets/views/admin/orders/index.html b/assets/views/admin/orders/index.html index e44897f..e8994e1 100644 --- a/assets/views/admin/orders/index.html +++ b/assets/views/admin/orders/index.html @@ -44,7 +44,7 @@ {{ ui::badge(label=t(key="order-status-" ~ order.status, lang=lang | default(value='sk')), variant="neutral") }} - {{ order.total }} {{ order.currency }} + {{ order.total }} € {{ ui::button(variant="outline-secondary", label=t(key="view", lang=lang | default(value='sk')), href="/admin/orders/" ~ order.id, size="px-3 py-1.5 text-xs") }} diff --git a/assets/views/admin/orders/show.html b/assets/views/admin/orders/show.html index d8d4f2e..40cedc8 100644 --- a/assets/views/admin/orders/show.html +++ b/assets/views/admin/orders/show.html @@ -38,14 +38,14 @@ {{ item.product_name }}{% if item.variant_label %} · {{ item.variant_label }}{% endif %} {{ item.quantity }} - {{ item.line_total }} {{ order.currency }} + {{ item.line_total }} € {% endfor %} {{ t(key="order-total", lang=lang | default(value='sk')) }} - {{ order.total }} {{ order.currency }} + {{ order.total }} € @@ -75,7 +75,7 @@

    {{ t(key="checkout-carrier", lang=lang | default(value='sk')) }}

    -

    {{ order.carrier_name }} — {{ order.shipping }} {{ order.currency }}

    +

    {{ order.carrier_name }} — {{ order.shipping }} €

    {% if order.pickup_point_name %}

    {{ order.pickup_point_name }}

    {% endif %}
    diff --git a/assets/views/macros/ui.html b/assets/views/macros/ui.html index 31ee1b2..7564736 100644 --- a/assets/views/macros/ui.html +++ b/assets/views/macros/ui.html @@ -132,10 +132,10 @@ {% macro eff_price(p, preview=false) -%} {%- if preview -%}{% set strong = "text-info" %}{%- else -%}{% set strong = "text-primary dark:text-primary-dark" %}{%- endif -%} {% if p.effective_reduced %} -{{ p.effective_price }} {{ p.currency }} +{{ p.effective_price }} € (−{{ p.effective_percent_off }}%) {% else %} -{{ p.effective_price }} {{ p.currency }} +{{ p.effective_price }} € {% endif %} {%- endmacro eff_price %} diff --git a/assets/views/shop/_card.html b/assets/views/shop/_card.html index ae8c8b4..8dcb4b2 100644 --- a/assets/views/shop/_card.html +++ b/assets/views/shop/_card.html @@ -38,11 +38,11 @@ {% endif %} {% if product.on_sale %}
    - Price{% if product.has_options %}{{ t(key="from-price", price=product.price, lang=lang | default(value='sk')) }}{% else %}{{ product.price }}{% endif %} {{ product.currency }} - {{ product.regular_price }} {{ product.currency }} + Price{% if product.has_options %}{{ t(key="from-price", price=product.price, lang=lang | default(value='sk')) }}{% else %}{{ product.price }}{% endif %} € + {{ product.regular_price }} €
    {% else %} - Price{% if product.has_options %}{{ t(key="from-price", price=product.price, lang=lang | default(value='sk')) }}{% else %}{{ product.price }}{% endif %} {{ product.currency }} + Price{% if product.has_options %}{{ t(key="from-price", price=product.price, lang=lang | default(value='sk')) }}{% else %}{{ product.price }}{% endif %} € {% endif %}
    diff --git a/assets/views/shop/_cart_body.html b/assets/views/shop/_cart_body.html index cfe0a94..cc4b352 100644 --- a/assets/views/shop/_cart_body.html +++ b/assets/views/shop/_cart_body.html @@ -23,10 +23,10 @@ {% if item.on_sale %} - {{ item.price }} {{ item.currency }} + {{ item.price }} € {{ item.regular_price }} {% else %} - {{ item.price }} {{ item.currency }} + {{ item.price }} € {% endif %} @@ -48,7 +48,7 @@ class="w-20 rounded-radius border border-outline bg-surface-alt px-2 py-1 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary disabled:cursor-not-allowed disabled:opacity-75 dark:border-outline-dark dark:bg-surface-dark-alt/50 dark:text-on-surface-dark dark:focus-visible:outline-primary-dark"> - {{ item.line_total }} {{ item.currency }} + {{ item.line_total }} €
    @@ -63,7 +63,7 @@ {{ t(key="cart-total", lang=lang | default(value='sk')) }} - {{ total }} {{ currency }} + {{ total }} € diff --git a/assets/views/shop/_cart_preview.html b/assets/views/shop/_cart_preview.html index be0e366..6075694 100644 --- a/assets/views/shop/_cart_preview.html +++ b/assets/views/shop/_cart_preview.html @@ -1,6 +1,6 @@ {# Mini-cart preview shown on hover over the navbar cart (Alza-style). Lazy-loaded via htmx from /partials/cart into the hover dropdown panel in - base.html. Receives: items[], total, currency, lang. #} + base.html. Receives: items[], total, lang. #} {% import "macros/ui.html" as ui %} {% if items | length > 0 %}
    @@ -9,16 +9,16 @@
    {{ item.name }} {% if item.variant_label %}{{ item.variant_label }}{% endif %} -

    {{ item.quantity }} × {{ item.price }} {{ item.currency }}

    +

    {{ item.quantity }} × {{ item.price }} €

    - {{ item.line_total }} {{ item.currency }} + {{ item.line_total }} €
    {% endfor %}
    {{ t(key="cart-total", lang=lang | default(value='sk')) }} - {{ total }} {{ currency }} + {{ total }} €
    {{ ui::button(href="/cart", variant="outline-primary", label=t(key="cart-title", lang=lang | default(value='sk')), extra="flex-1", attrs='hx-boost="false"') }} diff --git a/assets/views/shop/checkout.html b/assets/views/shop/checkout.html index d2d859e..27754b0 100644 --- a/assets/views/shop/checkout.html +++ b/assets/views/shop/checkout.html @@ -188,7 +188,7 @@ class="before:content[''] relative h-4 w-4 appearance-none rounded-full border border-outline bg-surface before:invisible before:absolute before:left-1/2 before:top-1/2 before:h-1.5 before:w-1.5 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:bg-on-primary checked:border-primary checked:bg-primary checked:before:visible focus:outline-2 focus:outline-offset-2 focus:outline-outline-strong checked:focus:outline-primary disabled:cursor-not-allowed dark:border-outline-dark dark:bg-surface-dark dark:before:bg-on-primary-dark dark:checked:border-primary-dark dark:checked:bg-primary-dark dark:focus:outline-outline-dark-strong dark:checked:focus:outline-primary-dark"> {{ m.name }} - {{ m.price }} {{ currency }} + {{ m.price }} € {% endfor %} @@ -252,23 +252,23 @@ {% for item in items %}
  • {{ item.name }} × {{ item.quantity }} - {{ item.line_total }} {{ item.currency }} + {{ item.line_total }} €
  • {% endfor %}
    {{ t(key="checkout-subtotal", lang=lang | default(value='sk')) }} - {{ subtotal }} {{ currency }} + {{ subtotal }} €
    {{ t(key="checkout-shipping-cost", lang=lang | default(value='sk')) }} - +
    {{ t(key="cart-total", lang=lang | default(value='sk')) }} - +
    {{ ui::button(label=t(key="checkout-place-order", lang=lang | default(value='sk')), type="submit", attrs=':disabled="!canSubmit"', extra="w-full", size="px-6 py-2.5 text-sm") }} diff --git a/assets/views/shop/order_confirmed.html b/assets/views/shop/order_confirmed.html index a6beae5..0dfd4a2 100644 --- a/assets/views/shop/order_confirmed.html +++ b/assets/views/shop/order_confirmed.html @@ -30,18 +30,18 @@ {% for item in items %}
  • {{ item.product_name }}{% if item.variant_label %} · {{ item.variant_label }}{% endif %} × {{ item.quantity }} - {{ item.line_total }} {{ order.currency }} + {{ item.line_total }} €
  • {% endfor %}
    -
    {{ t(key="checkout-subtotal", lang=lang | default(value='sk')) }}{{ order.subtotal }} {{ order.currency }}
    -
    {{ order.carrier_name }}{{ order.shipping }} {{ order.currency }}
    +
    {{ t(key="checkout-subtotal", lang=lang | default(value='sk')) }}{{ order.subtotal }} €
    +
    {{ order.carrier_name }}{{ order.shipping }} €
    {% if order.pickup_point_name %}
    {{ order.pickup_point_name }}
    {% endif %}
    {{ t(key="order-total", lang=lang | default(value='sk')) }} - {{ order.total }} {{ order.currency }} + {{ order.total }} €
    @@ -52,7 +52,7 @@ {{ t(key="bank-account-name", lang=lang | default(value='sk')) }}{{ order.bank_account_name }} IBAN{{ order.bank_iban }} {{ t(key="bank-variable-symbol", lang=lang | default(value='sk')) }}{{ order.variable_symbol }} - {{ t(key="bank-amount", lang=lang | default(value='sk')) }}{{ order.total }} {{ order.currency }} + {{ t(key="bank-amount", lang=lang | default(value='sk')) }}{{ order.total }} €
    {% else %} diff --git a/assets/views/shop/show.html b/assets/views/shop/show.html index 228b9fc..9a65eb2 100644 --- a/assets/views/shop/show.html +++ b/assets/views/shop/show.html @@ -67,7 +67,7 @@ @@ -75,10 +75,10 @@

    - {{ product.currency }} +

    diff --git a/migration/src/lib.rs b/migration/src/lib.rs index 7bb87da..9de9c52 100644 --- a/migration/src/lib.rs +++ b/migration/src/lib.rs @@ -47,6 +47,7 @@ mod m20260622_000005_product_search_aggregate; mod m20260622_000006_order_search_indexes; mod m20260623_000001_add_short_description_to_products; mod m20260623_000002_strip_html_from_product_search; +mod m20260623_000003_drop_currency; pub struct Migrator; #[async_trait::async_trait] @@ -98,6 +99,7 @@ impl MigratorTrait for Migrator { Box::new(m20260622_000006_order_search_indexes::Migration), Box::new(m20260623_000001_add_short_description_to_products::Migration), Box::new(m20260623_000002_strip_html_from_product_search::Migration), + Box::new(m20260623_000003_drop_currency::Migration), // inject-above (do not remove this comment) ] } diff --git a/migration/src/m20260623_000003_drop_currency.rs b/migration/src/m20260623_000003_drop_currency.rs new file mode 100644 index 0000000..93384ef --- /dev/null +++ b/migration/src/m20260623_000003_drop_currency.rs @@ -0,0 +1,20 @@ +use loco_rs::schema::*; +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> { + // The store is EUR-only. Currency is no longer stored per product/order; + // the euro symbol is rendered everywhere in the UI. + remove_column(m, "products", "currency").await?; + remove_column(m, "orders", "currency").await + } + + async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> { + add_column(m, "products", "currency", ColType::StringWithDefault("EUR".to_string())).await?; + add_column(m, "orders", "currency", ColType::StringWithDefault("EUR".to_string())).await + } +} diff --git a/src/controllers/admin_customers.rs b/src/controllers/admin_customers.rs index 630a7ff..cbd4163 100644 --- a/src/controllers/admin_customers.rs +++ b/src/controllers/admin_customers.rs @@ -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), diff --git a/src/controllers/admin_orders.rs b/src/controllers/admin_orders.rs index 9f7ba4d..fa6d01d 100644 --- a/src/controllers/admin_orders.rs +++ b/src/controllers/admin_orders.rs @@ -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, }; diff --git a/src/controllers/admin_products.rs b/src/controllers/admin_products.rs index 4c2deb7..7587840 100644 --- a/src/controllers/admin_products.rs +++ b/src/controllers/admin_products.rs @@ -53,7 +53,6 @@ struct ProductFields { slug: String, description: Option, short_description: Option, - currency: String, category_id: Option, 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::().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 { - 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, diff --git a/src/controllers/cart.rs b/src/controllers/cart.rs index 44a215a..a07c86b 100644 --- a/src/controllers/cart.rs +++ b/src/controllers/cart.rs @@ -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, ) -> Result { 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, ) -> Result { 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), }), )?; diff --git a/src/controllers/checkout.rs b/src/controllers/checkout.rs index 88638ba..d9ef45d 100644 --- a/src/controllers/checkout.rs +++ b/src/controllers/checkout.rs @@ -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 = 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, diff --git a/src/controllers/shop.rs b/src/controllers/shop.rs index 1ff58df..4bc8e2d 100644 --- a/src/controllers/shop.rs +++ b/src/controllers/shop.rs @@ -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, }), diff --git a/src/integrations/mod.rs b/src/integrations/mod.rs index c0bdb36..ed2e294 100644 --- a/src/integrations/mod.rs +++ b/src/integrations/mod.rs @@ -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, diff --git a/src/integrations/packeta.rs b/src/integrations/packeta.rs index ec495d1..36ef625 100644 --- a/src/integrations/packeta.rs +++ b/src/integrations/packeta.rs @@ -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), ); diff --git a/src/models/_entities/orders.rs b/src/models/_entities/orders.rs index 3e8712f..531dd08 100644 --- a/src/models/_entities/orders.rs +++ b/src/models/_entities/orders.rs @@ -16,7 +16,6 @@ pub struct Model { pub customer_name: Option, pub status: String, pub total_cents: i64, - pub currency: String, pub address: Option, pub city: Option, pub zip: Option, diff --git a/src/models/_entities/products.rs b/src/models/_entities/products.rs index 5b66a32..5ce2853 100644 --- a/src/models/_entities/products.rs +++ b/src/models/_entities/products.rs @@ -17,7 +17,6 @@ pub struct Model { pub description: Option, #[sea_orm(column_type = "Text", nullable)] pub short_description: Option, - pub currency: String, pub view_count: i32, pub published: bool, pub published_at: Option, diff --git a/src/models/orders.rs b/src/models/orders.rs index 5212550..d821e95 100644 --- a/src/models/orders.rs +++ b/src/models/orders.rs @@ -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), diff --git a/src/models/products.rs b/src/models/products.rs index b69b991..e4e86ba 100644 --- a/src/models/products.rs +++ b/src/models/products.rs @@ -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) diff --git a/src/seed.rs b/src/seed.rs index 0c5f2ed..35f39b3 100644 --- a/src/seed.rs +++ b/src/seed.rs @@ -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)), diff --git a/src/views/checkout.rs b/src/views/checkout.rs index c28c3ae..b135fe8 100644 --- a/src/views/checkout.rs +++ b/src/views/checkout.rs @@ -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(), }) } diff --git a/src/views/shop.rs b/src/views/shop.rs index f9db550..df30c51 100644 --- a/src/views/shop.rs +++ b/src/views/shop.rs @@ -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