mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Move voucher value to the model
Use Spree::Money to display amount with currency
This commit is contained in:
@@ -4,4 +4,12 @@ class Voucher < ApplicationRecord
|
||||
belongs_to :enterprise
|
||||
|
||||
validates :code, presence: true, uniqueness: { scope: :enterprise_id }
|
||||
|
||||
def value
|
||||
10
|
||||
end
|
||||
|
||||
def display_value
|
||||
Spree::Money.new(value)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
- @enterprise.vouchers.each do |voucher|
|
||||
%tr
|
||||
%td= voucher.code
|
||||
%td $10
|
||||
%td= voucher.display_value
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
|
||||
@@ -19,5 +19,5 @@
|
||||
.alpha.four.columns
|
||||
= f.label :amount, t('.voucher_amount')
|
||||
.omega.eight.columns
|
||||
$
|
||||
= f.text_field :amount, value: 10, disabled: true
|
||||
= Spree::Money.currency_symbol
|
||||
= f.text_field :amount, value: @voucher.value, disabled: true
|
||||
|
||||
Reference in New Issue
Block a user