Skip to content

Commit

Permalink
Fixed tax rates editing for tax zones in the admin backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikola Trandafilovic committed Nov 22, 2011
1 parent 8baaddc commit c71bf62
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/controllers/admin/tax_zone_taxes_controller.rb
Expand Up @@ -45,10 +45,10 @@ def create


respond_to do |format| respond_to do |format|
if @tax_zone_tax.save if @tax_zone_tax.save
format.html { redirect_to([:admin,@tax_zone_tax], :notice => 'Tax zone tax was successfully created.') } format.html { redirect_to admin_tax_zone_path(@tax_zone_tax.tax_zone) }
format.xml { render :xml => @tax_zone_tax, :status => :created, :location => @tax_zone_tax } #~ format.xml { render :xml => @tax_zone_tax, :status => :created, :location => @tax_zone_tax }
else else
format.html { render :action => "new" } #~ format.html { render :action => "new" }
format.xml { render :xml => @tax_zone_tax.errors, :status => :unprocessable_entity } format.xml { render :xml => @tax_zone_tax.errors, :status => :unprocessable_entity }
end end
end end
Expand All @@ -60,7 +60,7 @@ def update
@tax_zone_tax = TaxZoneTax.find(params[:id]) @tax_zone_tax = TaxZoneTax.find(params[:id])


respond_to do |format| respond_to do |format|
if @tax_zone_tax.update_attributes(params[:tax_zone_taxis]) if @tax_zone_tax.update_attributes(params[:tax_zone_taxes])
format.html { redirect_to([:admin,@tax_zone_tax], :notice => 'Tax zone tax was successfully updated.') } format.html { redirect_to([:admin,@tax_zone_tax], :notice => 'Tax zone tax was successfully updated.') }
format.xml { head :ok } format.xml { head :ok }
else else
Expand Down
2 changes: 1 addition & 1 deletion app/models/tax_zone.rb
@@ -1,5 +1,5 @@
class TaxZone < ActiveRecord::Base class TaxZone < ActiveRecord::Base
has_many :tax_zone_taxes has_many :tax_zone_taxes, :class_name => "TaxZoneTax"
has_many :county_tax_zones has_many :county_tax_zones
accepts_nested_attributes_for :county_tax_zones, :allow_destroy => false accepts_nested_attributes_for :county_tax_zones, :allow_destroy => false
accepts_nested_attributes_for :tax_zone_taxes, :allow_destroy => false accepts_nested_attributes_for :tax_zone_taxes, :allow_destroy => false
Expand Down
32 changes: 32 additions & 0 deletions app/views/admin/tax_zones/_tax_rates_form.html.erb
@@ -0,0 +1,32 @@
<table>
<tr>
<th><%= t(:tax_rate, :scope => :tax_rates) %></th>
<th><%= t(:from, :scope => :tax_rates) %></th>
<th></th>
</tr>
<% if !@tax_zone.tax_zone_taxes.blank? %>
<% @tax_zone.tax_zone_taxes.order('"from" asc').each do |tz| %>
<tr>
<td><%= tz.tax_rate %></td>
<td><%= tz.from %></td>
<td></td>
</tr>
<% end %>
<% end %>
<tr>
<% @tax_zone_tax = TaxZoneTax.new %>
<%= form_for([:admin,@tax_zone_tax]) do |f| %>
<%= f.hidden_field :tax_zone_id, :value => @tax_zone.id %>
<td>
<%= f.text_field :tax_rate %>
</td>
<td>
<%= f.text_field :from, :class => :datepicker %>
</td>
<td>
<%= f.submit t( :add_tax_rate, :scope => :tax_rates) %>
</td>
</tr>
<% end %>
</table>
1 change: 1 addition & 0 deletions app/views/admin/tax_zones/show.html.erb
Expand Up @@ -5,6 +5,7 @@
<%= @tax_zone.number %> <%= @tax_zone.number %>
</p> </p>


<%= render :partial => "tax_rates_form" %>
<%= link_to 'Edit', edit_admin_tax_zone_path(@tax_zone) %> | <%= link_to 'Edit', edit_admin_tax_zone_path(@tax_zone) %> |
<%= link_to 'Back', admin_tax_zones_path %> <%= link_to 'Back', admin_tax_zones_path %>

0 comments on commit c71bf62

Please sign in to comment.