1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

init spaces prices on plan creation

This commit is contained in:
Sylvain 2017-03-01 16:45:05 +01:00
parent 6df0a4090e
commit 2e094a501f

View File

@ -19,6 +19,7 @@ class Plan < ActiveRecord::Base
after_update :update_stripe_plan, if: :amount_changed?
after_create :create_stripe_plan, unless: :skip_create_stripe_plan
after_create :create_machines_prices
after_create :create_spaces_prices
after_create :create_statistic_type
after_destroy :delete_stripe_plan
@ -57,6 +58,12 @@ class Plan < ActiveRecord::Base
end
end
def create_spaces_prices
Space.all.each do |space|
Price.create(priceable: space, plan: self, group_id: self.group_id, amount: 0)
end
end
def duration
interval_count.send(interval)
end