14 lines
253 B
Ruby
14 lines
253 B
Ruby
|
class Expense < ApplicationRecord
|
||
|
PERIOD_OCCURENCES = {
|
||
|
monthly: 12,
|
||
|
annually: 1,
|
||
|
weekly: 52,
|
||
|
quarterly: 3,
|
||
|
}.freeze
|
||
|
enum :period, PERIOD_OCCURENCES.keys
|
||
|
|
||
|
def monthly
|
||
|
payment * PERIOD_OCCURENCES[period.to_sym] / 12
|
||
|
end
|
||
|
end
|