mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
Initialize new plans with default prices for machines & spaces
This commit is contained in:
parent
79b49778a4
commit
bf76157703
@ -4,6 +4,7 @@
|
||||
- Enabled Hot module replacement
|
||||
- Enlarged privacy policy display and edition zones
|
||||
- Removed fab-manager email address from the seeds
|
||||
- Initialize new plans with default prices for machines & spaces
|
||||
- Fix a bug: in the settings area, boolean switches are always shown as false
|
||||
- Fix a bug: public cards presenting the plans in the public area, have bogus style
|
||||
|
||||
|
@ -56,13 +56,15 @@ class Plan < ApplicationRecord
|
||||
|
||||
def create_machines_prices
|
||||
Machine.all.each do |machine|
|
||||
Price.create(priceable: machine, plan: self, group_id: group_id, amount: 0)
|
||||
default_price = Price.find_by(priceable: machine, plan: nil, group_id: group_id)&.amount || 0
|
||||
Price.create(priceable: machine, plan: self, group_id: group_id, amount: default_price)
|
||||
end
|
||||
end
|
||||
|
||||
def create_spaces_prices
|
||||
Space.all.each do |space|
|
||||
Price.create(priceable: space, plan: self, group_id: group_id, amount: 0)
|
||||
default_price = Price.find_by(priceable: space, plan: nil, group_id: group_id)&.amount || 0
|
||||
Price.create(priceable: space, plan: self, group_id: group_id, amount: default_price)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user