diff --git a/app/frontend/src/javascript/components/store/product-form.tsx b/app/frontend/src/javascript/components/store/product-form.tsx index 6bb1a36d6..07296e1be 100644 --- a/app/frontend/src/javascript/components/store/product-form.tsx +++ b/app/frontend/src/javascript/components/store/product-form.tsx @@ -280,7 +280,7 @@ export const ProductForm: React.FC = ({ product, title, onSucc diff --git a/app/frontend/src/javascript/components/store/product-item.tsx b/app/frontend/src/javascript/components/store/product-item.tsx index 177f460e7..c37f97dc1 100644 --- a/app/frontend/src/javascript/components/store/product-item.tsx +++ b/app/frontend/src/javascript/components/store/product-item.tsx @@ -79,12 +79,10 @@ export const ProductItem: React.FC = ({ product, onEdit, onDel {t('app.admin.store.product_item.stock.external')}

{product.stock.external}

- {product.amount && -
-

{FormatLib.price(product.amount)}

- / {t('app.admin.store.product_item.unit')} -
- } +
+

{FormatLib.price(product.amount || 0)}

+ / {t('app.admin.store.product_item.unit')} +
diff --git a/app/frontend/src/javascript/components/store/store-product-item.tsx b/app/frontend/src/javascript/components/store/store-product-item.tsx index fef8d883a..321dc4b1e 100644 --- a/app/frontend/src/javascript/components/store/store-product-item.tsx +++ b/app/frontend/src/javascript/components/store/store-product-item.tsx @@ -81,12 +81,10 @@ export const StoreProductItem: React.FC = ({ product, car

{product.name}

- {product.amount && -
-

{FormatLib.price(product.amount)}

- / {t('app.public.store_product_item.unit')} -
- } +
+

{FormatLib.price(product.amount || 0)}

+ / {t('app.public.store_product_item.unit')} +
{productStockStatus(product)} diff --git a/app/frontend/src/javascript/components/store/store-product.tsx b/app/frontend/src/javascript/components/store/store-product.tsx index ac02b0931..4ebae268a 100644 --- a/app/frontend/src/javascript/components/store/store-product.tsx +++ b/app/frontend/src/javascript/components/store/store-product.tsx @@ -180,7 +180,7 @@ export const StoreProduct: React.FC = ({ productSlug, current {productStockStatus(product)}
-

{FormatLib.price(product.amount)} TTC

+

{FormatLib.price(product.amount || 0)} TTC

/ {t('app.public.store_product_item.unit')}
{product.stock.external > (product.quantity_min || 1) && diff --git a/app/models/product.rb b/app/models/product.rb index 682a3f8fe..449543756 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -20,7 +20,7 @@ class Product < ApplicationRecord accepts_nested_attributes_for :product_stock_movements, allow_destroy: true, reject_if: :all_blank validates :name, :slug, presence: true - validates :amount, numericality: { greater_than: 0, allow_nil: true } + validates :amount, numericality: { greater_than_or_equal_to: 0, allow_nil: true } scope :active, -> { where(is_active: true) } diff --git a/app/services/cart/add_item_service.rb b/app/services/cart/add_item_service.rb index 31477a180..4fbc4ea3a 100644 --- a/app/services/cart/add_item_service.rb +++ b/app/services/cart/add_item_service.rb @@ -11,7 +11,7 @@ class Cart::AddItemService quantity = orderable.quantity_min > quantity.to_i && item.nil? ? orderable.quantity_min : quantity.to_i if item.nil? - item = order.order_items.new(quantity: quantity, orderable: orderable, amount: orderable.amount) + item = order.order_items.new(quantity: quantity, orderable: orderable, amount: orderable.amount || 0) else item.quantity += quantity.to_i end