Class: BudgetGeneratorWorker
Instance Attribute Summary
#broadcast_status_updates
Instance Method Summary
collapse
#at, #store, #total
Instance Method Details
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/workers/budget_generator_worker.rb', line 8
def perform(options = {})
options = options.with_indifferent_access
current_user = Party.find(options['current_user_id'])
company = Company.find(options['company_id'])
currency = company.currency
closed_to_date = Budget.closed_to_date(company)
business_units = BusinessUnit.order(:number).all
budget_rules = BudgetRule.all
exchange_rate = options['exchange_rate'].blank? ? nil : BigDecimal(options['exchange_rate'])
total budget_rules.length
num = 0
budget_rules.each do |br|
at(num, "At #{num}")
Budget.generate_for_rule(br, company, currency, closed_to_date, business_units, options['year'].to_i, options['month'].to_i,
options['exchange_rate'])
num += 1
end
BudgetRefresherWorker.perform_async(options['year'], options['month'])
end
|