Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed tax rates editing for tax zones in the admin backend

  • Loading branch information...
commit c71bf628e868fae7530271078583d1e3e16b7e68 1 parent 8baaddc
Nikola Trandafilovic authored
View
8 app/controllers/admin/tax_zone_taxes_controller.rb
@@ -45,10 +45,10 @@ def create
respond_to do |format|
if @tax_zone_tax.save
- format.html { redirect_to([:admin,@tax_zone_tax], :notice => 'Tax zone tax was successfully created.') }
- format.xml { render :xml => @tax_zone_tax, :status => :created, :location => @tax_zone_tax }
+ 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 }
else
- format.html { render :action => "new" }
+ #~ format.html { render :action => "new" }
format.xml { render :xml => @tax_zone_tax.errors, :status => :unprocessable_entity }
end
end
@@ -60,7 +60,7 @@ def update
@tax_zone_tax = TaxZoneTax.find(params[:id])
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.xml { head :ok }
else
View
2  app/models/tax_zone.rb
@@ -1,5 +1,5 @@
class TaxZone < ActiveRecord::Base
- has_many :tax_zone_taxes
+ has_many :tax_zone_taxes, :class_name => "TaxZoneTax"
has_many :county_tax_zones
accepts_nested_attributes_for :county_tax_zones, :allow_destroy => false
accepts_nested_attributes_for :tax_zone_taxes, :allow_destroy => false
View
32 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>
View
1  app/views/admin/tax_zones/show.html.erb
@@ -5,6 +5,7 @@
<%= @tax_zone.number %>
</p>
+<%= render :partial => "tax_rates_form" %>
<%= link_to 'Edit', edit_admin_tax_zone_path(@tax_zone) %> |
<%= link_to 'Back', admin_tax_zones_path %>
Please sign in to comment.
Something went wrong with that request. Please try again.