tax profiles
This commit is contained in:
@@ -7,7 +7,17 @@ class Settings::TaxProfilesController < ApplicationController
|
||||
def index
|
||||
@settings_tax_profiles = TaxProfile.all
|
||||
tax_profiles = Lookup.collection_of("tax_profiles")
|
||||
|
||||
if !@settings_tax_profiles.nil?
|
||||
@settings_tax_profiles.each_with_index do |setting_tax_profile, tax_index|
|
||||
if !tax_profiles.nil?
|
||||
tax_profiles.each do |group|
|
||||
if setting_tax_profile.group_type == group[1]
|
||||
@settings_tax_profiles[tax_index].group_type = group[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# GET /settings/tax_profiles/1
|
||||
@@ -17,11 +27,19 @@ class Settings::TaxProfilesController < ApplicationController
|
||||
|
||||
# GET /settings/tax_profiles/new
|
||||
def new
|
||||
@name = nil
|
||||
@settings_tax_profile = TaxProfile.new
|
||||
@tax_profiles = TaxProfile.all
|
||||
end
|
||||
|
||||
# GET /settings/tax_profiles/1/edit
|
||||
def edit
|
||||
@settings_tax_profile = TaxProfile.find(params[:id])
|
||||
@name = nil
|
||||
if !@settings_tax_profile.nil?
|
||||
@name = @settings_tax_profile.name
|
||||
end
|
||||
@tax_profiles = TaxProfile.all
|
||||
end
|
||||
|
||||
# POST /settings/tax_profiles
|
||||
@@ -71,6 +89,16 @@ class Settings::TaxProfilesController < ApplicationController
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_tax_profile
|
||||
@settings_tax_profile = TaxProfile.find(params[:id])
|
||||
tax_profiles = Lookup.collection_of("tax_profiles")
|
||||
if !@settings_tax_profile.nil?
|
||||
if !tax_profiles.nil?
|
||||
tax_profiles.each do |group|
|
||||
if @settings_tax_profile.group_type == group[1]
|
||||
@settings_tax_profile.group_type = group[0]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
||||
@@ -9,14 +9,15 @@
|
||||
|
||||
<div class="form-inputs p-l-15">
|
||||
<%= f.input :group_type, :collection => Lookup.collection_of("tax_profiles"),:input_html=>{:class=>"col-md-10"},:required=>true %>
|
||||
<%= f.input :name %>
|
||||
<%= f.input :name, :input_html=>{:onchange=>"checkDuplicate(this.value);"} %>
|
||||
<span id="tax_profile_nameErr" style="color:red;"></span>
|
||||
<%= f.input :rate %>
|
||||
<%= f.input :inclusive %>
|
||||
<%= f.input :order_by %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions p-l-15">
|
||||
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
|
||||
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect btn_submit' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -46,5 +47,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function checkDuplicate(obj){
|
||||
// $("#tax_profile_nameErr").html("");
|
||||
var name = '<%= @name %>';
|
||||
var tax_profiles = JSON.parse('<%= @tax_profiles.to_json.html_safe %>');
|
||||
var group_type = $("#tax_profile_group_type").val();
|
||||
if(tax_profiles!=undefined && tax_profiles!=null && tax_profiles!=""){
|
||||
$.each(tax_profiles,function(key,value){
|
||||
if(value.group_type == group_type){
|
||||
if(name.trim().toLowerCase()!=value.name.trim().toLowerCase()){
|
||||
if(value.name.trim().toLowerCase() == obj.trim().toLowerCase()){
|
||||
$("#tax_profile_name").val("");
|
||||
$("#tax_profile_nameErr").html("duplicate group type and name");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@
|
||||
<tbody>
|
||||
<% @settings_tax_profiles.each do |settings_tax_profile| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= settings_tax_profile.group_type %>
|
||||
</td>
|
||||
<td><%= settings_tax_profile.group_type %></td>
|
||||
<td><%= settings_tax_profile.name %></td>
|
||||
<td><%= settings_tax_profile.rate %></td>
|
||||
<td><%= settings_tax_profile.inclusive %></td>
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
<div class="card-block">
|
||||
<h4 class="card-title"><%= t("en.tax_profile") %></h4>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td><strong><%= t("views.right_panel.detail.group_type") %>:</strong></td>
|
||||
<td><%= @settings_tax_profile.group_type %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><strong><%= t("views.right_panel.detail.name") %>:</strong></td>
|
||||
<td><%= @settings_tax_profile.name %></td>
|
||||
|
||||
Reference in New Issue
Block a user