3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/helpers/admin/activity_tax_controller_helper.rb', line 3
def on_tax_observation
render(:update) do |page|
begin
tax_percent, tax_flat = Setting.grab :sales_tax_percent, :sales_tax_flat
tax_percent = tax_percent.to_f
tax_flat = tax_flat.to_f
id_suffix = (params[:eid] ? '_' : '')+params[:record_id]
tax_field_id = options_for_column(:tax)[:id] + id_suffix
cost_field_id = options_for_column(:cost)[:id] + id_suffix
tax_field_hidden_id = "%s_hidden" % tax_field_id
page[cost_field_id].value = money_for_input(params[:cost].to_f)
if params['apply_tax'] == 'yes'
page[tax_field_id].value = money_for_input(params[:cost].to_f * (tax_percent/100) + tax_flat)
page[tax_field_id].enable
page[tax_field_hidden_id].disable
page[tax_field_id].removeClassName "disabled"
else
page[tax_field_id].value = ''
page[tax_field_id].disable
page[tax_field_hidden_id].enable
page[tax_field_id].addClassName "disabled"
end
rescue
page.alert 'Error updating form Record(%s) "%s"' % [params[:record_id], $!]
end
end
end
|