mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(feat) allow product price = 0
This commit is contained in:
parent
906931f40f
commit
1aa058f3d6
@ -280,7 +280,7 @@ export const ProductForm: React.FC<ProductFormProps> = ({ product, title, onSucc
|
||||
<FormInput id="amount"
|
||||
type="number"
|
||||
register={register}
|
||||
rules={{ required: true, min: 0.01 }}
|
||||
rules={{ required: true, min: 0 }}
|
||||
step={0.01}
|
||||
formState={formState}
|
||||
label={t('app.admin.store.product_form.price')} />
|
||||
|
@ -79,12 +79,10 @@ export const ProductItem: React.FC<ProductItemProps> = ({ product, onEdit, onDel
|
||||
<span>{t('app.admin.store.product_item.stock.external')}</span>
|
||||
<p>{product.stock.external}</p>
|
||||
</div>
|
||||
{product.amount &&
|
||||
<div className='price'>
|
||||
<p>{FormatLib.price(product.amount)}</p>
|
||||
<span>/ {t('app.admin.store.product_item.unit')}</span>
|
||||
</div>
|
||||
}
|
||||
<div className='price'>
|
||||
<p>{FormatLib.price(product.amount || 0)}</p>
|
||||
<span>/ {t('app.admin.store.product_item.unit')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className='actions'>
|
||||
<div className='manage'>
|
||||
|
@ -81,12 +81,10 @@ export const StoreProductItem: React.FC<StoreProductItemProps> = ({ product, car
|
||||
<img src={productImageUrl(product)} alt='' />
|
||||
</div>
|
||||
<p className="name">{product.name}</p>
|
||||
{product.amount &&
|
||||
<div className='price'>
|
||||
<p>{FormatLib.price(product.amount)}</p>
|
||||
<span>/ {t('app.public.store_product_item.unit')}</span>
|
||||
</div>
|
||||
}
|
||||
<div className='price'>
|
||||
<p>{FormatLib.price(product.amount || 0)}</p>
|
||||
<span>/ {t('app.public.store_product_item.unit')}</span>
|
||||
</div>
|
||||
<FabStateLabel status={statusColor(product)}>
|
||||
{productStockStatus(product)}
|
||||
</FabStateLabel>
|
||||
|
@ -180,7 +180,7 @@ export const StoreProduct: React.FC<StoreProductProps> = ({ productSlug, current
|
||||
{productStockStatus(product)}
|
||||
</FabStateLabel>
|
||||
<div className='price'>
|
||||
<p>{FormatLib.price(product.amount)} <sup>TTC</sup></p>
|
||||
<p>{FormatLib.price(product.amount || 0)} <sup>TTC</sup></p>
|
||||
<span>/ {t('app.public.store_product_item.unit')}</span>
|
||||
</div>
|
||||
{product.stock.external > (product.quantity_min || 1) &&
|
||||
|
@ -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) }
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user